From: romibi Date: Sat, 9 Jul 2016 16:30:44 +0000 (+0200) Subject: Fix cmd+Q invalidating the layout somehow X-Git-Tag: travis-deploy-test~404 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=89175f57858e885d23dac1401f6f14db20ba9002 Fix cmd+Q invalidating the layout somehow On Mac OSX Qt Applications (with Frameworks packaged) receive the CloseEvent twice. (See https://bugreports.qt.io/browse/QTBUG-43344) This triggers a bug where Quassels Main-Window stays hidden and all Layout states get reset on next launch. Workaround by checking if event already received... Resolves GH-230. --- diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 6e681e44..eb02b430 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -173,7 +173,8 @@ MainWin::MainWin(QWidget *parent) _titleSetter(this), _awayLog(0), _layoutLoaded(false), - _activeBufferViewIndex(-1) + _activeBufferViewIndex(-1), + _aboutToQuit(false) { setAttribute(Qt::WA_DeleteOnClose, false); // we delete the mainwin manually @@ -1509,14 +1510,21 @@ void MainWin::closeEvent(QCloseEvent *event) QtUiSettings s; QtUiApplication *app = qobject_cast qApp; Q_ASSERT(app); - if (!app->isAboutToQuit() && QtUi::haveSystemTray() && s.value("MinimizeOnClose").toBool()) { + // On OSX it can happen that the closeEvent occurs twice. (Especially if packaged with Frameworks) + // This messes up MainWinState/MainWinHidden save/restore. + // It's a bug in Qt: https://bugreports.qt.io/browse/QTBUG-43344 + if (!_aboutToQuit && !app->isAboutToQuit() && QtUi::haveSystemTray() && s.value("MinimizeOnClose").toBool()) { QtUi::hideMainWidget(); event->ignore(); } - else { + else if(!_aboutToQuit) { + _aboutToQuit = true; event->accept(); quit(); } + else { + event->ignore(); + } } diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index 93a71127..efe91c65 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -225,5 +225,7 @@ private: QHash _jumpKeyMap; int _activeBufferViewIndex; + bool _aboutToQuit; //closeEvent can occur multiple times on OSX + friend class QtUi; };