X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fmainwin.cpp;h=8d122f390d3f04568bc444d1cd0c557954ce003c;hp=801fab8b70e2fa9824cd981322f8167723c1a853;hb=72473527f99cbe68dcfcb4ca17f828bd3775bba7;hpb=ee3e3d298a1208d06e3a35a8aea6bcc42ce3aa5c diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 801fab8b..8d122f39 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -305,21 +305,17 @@ void MainWin::init() // restore locked state of docks QtUi::actionCollection("General")->action("LockLayout")->setChecked(s.value("LockLayout", false).toBool()); - QTimer::singleShot(0, this, SLOT(doAutoConnect())); -} - - -MainWin::~MainWin() -{ -} + Quassel::registerQuitHandler([this]() { + QtUiSettings s; + saveStateToSettings(s); + saveLayout(); + // Close all open dialogs and the MainWin, so we can safely kill the Client instance afterwards + // Note: This does not quit the application, as quitOnLastWindowClosed is set to false. + // We rely on another quit handler to be registered that actually quits the application. + qApp->closeAllWindows(); + }); - -void MainWin::quit() -{ - QtUiSettings s; - saveStateToSettings(s); - saveLayout(); - QApplication::quit(); + QTimer::singleShot(0, this, SLOT(doAutoConnect())); } @@ -416,7 +412,7 @@ void MainWin::setupActions() // // See https://doc.qt.io/qt-5/qkeysequence.html coll->addAction("Quit", new Action(icon::get("application-exit"), tr("&Quit"), coll, - this, SLOT(quit()), Qt::CTRL + Qt::Key_Q)); + Quassel::instance(), SLOT(quit()), Qt::CTRL + Qt::Key_Q)); // View coll->addAction("ConfigureBufferViews", new Action(tr("&Configure Chat Lists..."), coll, @@ -1731,7 +1727,7 @@ void MainWin::closeEvent(QCloseEvent *event) else if(!_aboutToQuit) { _aboutToQuit = true; event->accept(); - quit(); + Quassel::instance()->quit(); } else { event->ignore();