From 8c43f5ad67f75c2160cd37209dbe93c7fe4e97f4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jul 2015 17:01:47 +0200 Subject: sc: try fix load failure logic --- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'ftnoir_protocol_sc') diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 4d76df03..465d8d20 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -76,7 +76,7 @@ void FTNoIR_Protocol::pose( const double *headpose ) { class ActivationContext { public: - ActivationContext(const int resid) { + ActivationContext(const int resid) :ok (false) { hactctx = INVALID_HANDLE_VALUE; actctx_cookie = 0; ACTCTXA actx = {0}; @@ -100,7 +100,7 @@ public: hactctx = INVALID_HANDLE_VALUE; } } else { - qDebug() << "SC: can't create win32 activation context"; + qDebug() << "SC: can't create win32 activation context" << GetLastError(); } } ~ActivationContext() { @@ -110,9 +110,11 @@ public: ReleaseActCtx(hactctx); } } + bool is_ok() { return ok; } private: ULONG_PTR actctx_cookie; HANDLE hactctx; + bool ok; }; bool FTNoIR_Protocol::correct() @@ -121,11 +123,16 @@ bool FTNoIR_Protocol::correct() { ActivationContext ctx(142 + static_cast(s.sxs_manifest)); - SCClientLib.setFileName("SimConnect.dll"); - if (!SCClientLib.load()) { - qDebug() << "SC load" << SCClientLib.errorString(); - return false; + if (ctx.is_ok()) + { + SCClientLib.setFileName("SimConnect.dll"); + if (!SCClientLib.load()) { + qDebug() << "SC load" << SCClientLib.errorString(); + return false; + } } + else + return false; } // -- cgit v1.2.3