summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-12-17 07:47:29 -0500
committerGitHub <noreply@github.com>2019-12-17 07:47:29 -0500
commita4a0e59d8ce7d3f9fbe0806a5621c27932f26314 (patch)
tree37e4a9046a8204cc3b70ae8937aae6dab1d9f167 /src/mainwindow.cpp
parent2c7e0e7cb4d8bf5c51f22968a5ffd2366d6bcdf2 (diff)
parent05231eab45f86e3d0d342c429e35c8f7c813ea42 (diff)
Merge pull request #942 from isanae/lock-fixes
Lock fixes
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp41
1 files changed, 35 insertions, 6 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index a29ea8ab..284c33e3 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1306,6 +1306,21 @@ void MainWindow::onBeforeClose()
void MainWindow::closeEvent(QCloseEvent* event)
{
+ if (isVisible()) {
+ // this is messy
+ //
+ // the main problem this is solving is when closing MO, then getting the
+ // lock overlay because processes are still running, then pressing the X
+ // again
+ //
+ // in this case, closeEvent() is _not_ called for the second event and the
+ // window is immediately hidden
+ //
+ // this always saves the settings here; in the event where a lock overlay
+ // is then shown, it might save settings multiple times, but it's harmless
+ onBeforeClose();
+ }
+
// this happens for two reasons:
// 1) the user requested to close the window, such as clicking the X
// 2) close() is called in runApplication() after application.exec()
@@ -1317,18 +1332,32 @@ void MainWindow::closeEvent(QCloseEvent* event)
//
// for 2), the settings have been saved and the window can just close
- if (ModOrganizerExiting()) {
+ if (ModOrganizerCanCloseNow()) {
// the user has confirmed if necessary and all settings have been saved,
// just close it
QMainWindow::closeEvent(event);
- } else {
- // never close the window because settings might need to be changed
+ return;
+ }
+
+ if (UILocker::instance().locked()) {
+ // don't bother asking the user to confirm if the ui is already locked
event->ignore();
+ ExitModOrganizer(Exit::Force);
+ return;
+ }
- // start the process of exiting, which may require confirmation by calling
- // canExit(), among other things
- ExitModOrganizer();
+ if (ModOrganizerExiting()) {
+ // ignore repeated attempts
+ event->ignore();
+ return;
}
+
+ // never close the window because settings might need to be changed
+ event->ignore();
+
+ // start the process of exiting, which may require confirmation by calling
+ // canExit(), among other things
+ ExitModOrganizer();
}
bool MainWindow::canExit()