diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-09-03 09:33:19 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-09-03 09:33:31 +0200 |
commit | 66054ee6ccd0e86534c42167d9e93704f7995db8 (patch) | |
tree | a3dbdd5fddaea8ebb1ccd8e0562ef5a297bb176b | |
parent | 9a8fde2d6dbd4aad8fa15b50fb4f8483202dbcb4 (diff) |
ui: force saving if saving timer is pending
Force saving when tracking is stopping at least. Due to "struct work"
being destroyed, unsaved settings revert to last saved.
So before "struct work" destruction need to save if save is pending.
Issue: #179
-rw-r--r-- | facetracknoir/ui.cpp | 13 | ||||
-rw-r--r-- | facetracknoir/ui.h | 1 |
2 files changed, 13 insertions, 1 deletions
diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 6437b9d1..4d93f3b2 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -124,7 +124,7 @@ MainWindow::~MainWindow() if (tray) tray->hide(); stopTracker(); - _save(); + maybe_save(); } void MainWindow::set_working_directory() @@ -142,6 +142,15 @@ void MainWindow::save() save_timer.start(5000); } +void MainWindow::maybe_save() +{ + if (save_timer.isActive()) + { + save_timer.stop(); + _save(); + } +} + void MainWindow::_save() { s.b->save(); save_mappings(); @@ -307,6 +316,8 @@ void MainWindow::stopTracker( ) { if (pFilterDialog) pFilterDialog->unregister_filter(); + maybe_save(); + work = nullptr; libs = SelectedLibraries(); diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index cfaf47cb..91e4ebbf 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -75,6 +75,7 @@ class MainWindow : public QMainWindow, private State void set_title(const QString& game_title = QStringLiteral("")); static bool get_new_config_name_from_dialog(QString &ret); void set_profile(const QString& profile); + void maybe_save(); private slots: void _save(); void save(); |