From be1b4e083d3599d4e0ad1f483ff5fe1f7ee1178f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 6 Apr 2016 17:35:09 +0200 Subject: proto/ft: only clear registry path on program exit Clear registry path when opentrack exits, not merely tracking is stopped. This is still controlled by the checkbox, while checking for being the first instance happens always regardless. Also update dialog description. Issue: #332 --- proto-ft/ftnoir_ftcontrols.ui | 6 +++--- proto-ft/ftnoir_protocol_ft.cpp | 1 - proto-ft/ftnoir_protocol_ft.h | 1 - proto-ft/mutex.cpp | 29 ++++++++++++++--------------- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/proto-ft/ftnoir_ftcontrols.ui b/proto-ft/ftnoir_ftcontrols.ui index b63d92a1..10c2c427 100755 --- a/proto-ft/ftnoir_ftcontrols.ui +++ b/proto-ft/ftnoir_ftcontrols.ui @@ -12,8 +12,8 @@ 0 0 - 511 - 413 + 503 + 379 @@ -212,7 +212,7 @@ Starting tracking will again overwrite the DLL locations. - Disable on protocol exit + Disable on program exit diff --git a/proto-ft/ftnoir_protocol_ft.cpp b/proto-ft/ftnoir_protocol_ft.cpp index 121da494..42671b8f 100755 --- a/proto-ft/ftnoir_protocol_ft.cpp +++ b/proto-ft/ftnoir_protocol_ft.cpp @@ -32,7 +32,6 @@ FTNoIR_Protocol::~FTNoIR_Protocol() dummyTrackIR.terminate(); dummyTrackIR.kill(); dummyTrackIR.waitForFinished(50); - runonce_check->try_exit(); } void FTNoIR_Protocol::pose(const double* headpose) { diff --git a/proto-ft/ftnoir_protocol_ft.h b/proto-ft/ftnoir_protocol_ft.h index b5b802bd..061504d9 100755 --- a/proto-ft/ftnoir_protocol_ft.h +++ b/proto-ft/ftnoir_protocol_ft.h @@ -43,7 +43,6 @@ typedef void (__stdcall *importTIRViewsStop)(void); struct runonce { virtual void try_runonce() = 0; - virtual void try_exit() = 0; virtual bool is_first_run() = 0; virtual ~runonce() {} virtual void set_enabled(bool flag) = 0; diff --git a/proto-ft/mutex.cpp b/proto-ft/mutex.cpp index 34f5f518..88021810 100755 --- a/proto-ft/mutex.cpp +++ b/proto-ft/mutex.cpp @@ -7,7 +7,20 @@ class check_for_first_run : public runonce bool is_first_instance; bool enabled; + void try_exit() + { + if (is_first_instance && enabled) + { + qDebug() << "ft runonce: removing registry keys"; + FTNoIR_Protocol::set_protocols(false, false); + } + } + public: + check_for_first_run() : checked_for_first_run(false), is_first_instance(false), enabled(false) + { + } + bool is_first_run() override { return checked_for_first_run && is_first_instance; @@ -23,7 +36,7 @@ public: { constexpr const char* name = "opentrack-freetrack-runonce"; - if (checked_for_first_run || !enabled) + if (checked_for_first_run) return; // just leak it, no issue @@ -49,20 +62,6 @@ public: qDebug() << "ft runonce:" << "first-run" << is_first_instance << "checked" << checked_for_first_run; } - void try_exit() override - { - if (is_first_instance && enabled) - { - qDebug() << "ft runonce: removing registry keys"; - FTNoIR_Protocol::set_protocols(false, false); - } - } - -public: - check_for_first_run() : checked_for_first_run(false), is_first_instance(false), enabled(false) - { - } - ~check_for_first_run() { try_exit(); -- cgit v1.2.3