summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-07-03 11:50:41 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-07-03 12:05:28 +0200
commit6aa89934e8f22a580dc8a63cec61fb9ea9d14f23 (patch)
tree4e640cc9ff28c24e7cdd422884da5f18eb28b54e
parent2d0ecf757c91c12d9a73420c5f142b652b5e3d7c (diff)
simconnect: prevent crash with no .dll
-rw-r--r--ftnoir_protocol_sc/ftnoir_protocol_sc.cpp12
-rw-r--r--ftnoir_protocol_sc/ftnoir_protocol_sc.h2
2 files changed, 10 insertions, 4 deletions
diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp
index 41fcf1b0..8e35248e 100644
--- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp
+++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp
@@ -31,7 +31,7 @@
static QLibrary SCClientLib;
-FTNoIR_Protocol::FTNoIR_Protocol() : should_stop(false), hSimConnect(nullptr)
+FTNoIR_Protocol::FTNoIR_Protocol() : should_stop(false), hSimConnect(nullptr), should_start(false)
{
start();
}
@@ -40,13 +40,13 @@ FTNoIR_Protocol::~FTNoIR_Protocol()
{
should_stop = true;
wait();
-
- if (hSimConnect)
- (void) simconnect_close(hSimConnect);
}
void FTNoIR_Protocol::run()
{
+ if (!should_start)
+ return;
+
if (SUCCEEDED(simconnect_open(&hSimConnect, "FaceTrackNoIR", NULL, 0, 0, 0))) {
simconnect_subscribetosystemevent(hSimConnect, EVENT_PING, "Frame");
@@ -62,6 +62,8 @@ void FTNoIR_Protocol::run()
(void) (simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, reinterpret_cast<void*>(this)));
Sleep(3);
}
+
+ (void) simconnect_close(hSimConnect);
}
void FTNoIR_Protocol::pose( const double *headpose ) {
@@ -182,6 +184,8 @@ bool FTNoIR_Protocol::correct()
}
qDebug() << "FTNoIR_Protocol::correct() says: SimConnect functions resolved in DLL!";
+
+ should_start = true;
return true;
}
diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h
index b65bac85..3ced16e5 100644
--- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h
+++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h
@@ -126,6 +126,8 @@ private:
HANDLE hSimConnect; // Handle to SimConnect
static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext);
settings s;
+
+ bool should_start;
};
class SCControls: public IProtocolDialog