diff options
Diffstat (limited to 'variant')
-rw-r--r-- | variant/default/main-window.cpp | 19 | ||||
-rw-r--r-- | variant/default/main-window.hpp | 6 |
2 files changed, 19 insertions, 6 deletions
diff --git a/variant/default/main-window.cpp b/variant/default/main-window.cpp index d6df6b8f..6529db11 100644 --- a/variant/default/main-window.cpp +++ b/variant/default/main-window.cpp @@ -135,11 +135,11 @@ main_window::main_window() : State(OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH) // timers connect(&config_list_timer, &QTimer::timeout, this, [this] { refresh_config_list(); }); - connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(show_pose()), Qt::DirectConnection); + connect(&pose_update_timer, &QTimer::timeout, this, &main_window::show_pose, Qt::DirectConnection); connect(&det_timer, SIGNAL(timeout()), this, SLOT(maybe_start_profile_from_executable())); // ctrl+q exits - connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); + connect(&kbd_quit, &QShortcut::activated, this, [this]() { main_window::exit(EXIT_SUCCESS); }, Qt::DirectConnection); // profile menu { @@ -793,11 +793,22 @@ void main_window::show_mapping_window() void main_window::exit(int status) { - QApplication::setQuitOnLastWindowClosed(true); + // don't use std::call_once here, leads to freeze in Microsoft's CRT + // this function never needs reentrancy anyway + + // this is probably harmless, but better safe than sorry + if (exiting_already) + return; + exiting_already = true; + + qDebug() << "opentrack: exiting"; + if (tray) tray->hide(); tray = nullptr; - close(); + + //close(); + QApplication::setQuitOnLastWindowClosed(true); QApplication::exit(status); } diff --git a/variant/default/main-window.hpp b/variant/default/main-window.hpp index 3c55be9e..55fca177 100644 --- a/variant/default/main-window.hpp +++ b/variant/default/main-window.hpp @@ -69,15 +69,17 @@ class main_window final : public QMainWindow, private State menu_action_options { &tray_menu }, menu_action_mappings { &tray_menu }; + bool exiting_already { false }; + using dylib_ptr = Modules::dylib_ptr; using dylib_list = Modules::dylib_list; - static std::tuple<dylib_ptr, int> module_by_name(const QString& name, Modules::dylib_list& list); - dylib_ptr current_tracker(); dylib_ptr current_protocol(); dylib_ptr current_filter(); + static std::tuple<dylib_ptr, int> module_by_name(const QString& name, Modules::dylib_list& list); + void update_button_state(bool running, bool inertialp); void display_pose(const double* mapped, const double* raw); void set_title(const QString& game_title = QString()); |