diff --git a/src/gui/application.cpp b/src/gui/application.cpp index a8b3929b6ef..3e5148abd3c 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -101,6 +101,8 @@ Application::Application(int &argc, char **argv) : _userTriggeredConnect(false), _debugMode(false) { + _startedAt.start(); + // TODO: Can't set this without breaking current config pathes // setOrganizationName(QLatin1String(APPLICATION_VENDOR)); setOrganizationDomain(QLatin1String(APPLICATION_REV_DOMAIN)); @@ -301,6 +303,12 @@ void Application::slotParseMessage(const QString &msg, QObject*) parseOptions(options); setupLogging(); } else if (msg.startsWith(QLatin1String("MSG_SHOWSETTINGS"))) { + qDebug() << "Running for" << _startedAt.elapsed()/1000.0 << "sec"; + if (isSessionRestored() && _startedAt.elapsed() < 10*1000) { + // This call is mirrored with the one in int main() + qWarning() << "Ignoring MSG_SHOWSETTINGS, possibly double-invocation of client via session restore and auto start"; + return; + } showSettingsDialog(); } } diff --git a/src/gui/application.h b/src/gui/application.h index 7a246e6c5a3..5381209188a 100644 --- a/src/gui/application.h +++ b/src/gui/application.h @@ -19,6 +19,7 @@ #include #include #include +#include #include "qtsingleapplication.h" @@ -97,6 +98,8 @@ protected slots: bool _helpOnly; bool _versionOnly; + QElapsedTimer _startedAt; + // options from command line: bool _showLogWindow; QString _logFile; diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 49cd4af408b..83c38063fae 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -89,6 +89,7 @@ int main(int argc, char **argv) if(app.isRunning()) { qDebug() << Q_FUNC_INFO << "Already running, exiting..."; if (app.isSessionRestored()) { + // This call is mirrored with the one in Application::slotParseMessage qDebug() << "Session was restored, don't notify app!"; return -1; } @@ -99,8 +100,9 @@ int main(int argc, char **argv) if(!app.sendMessage(QLatin1String("MSG_PARSEOPTIONS:") + msg)) return -1; } - if(!app.sendMessage(QLatin1String("MSG_SHOWSETTINGS"))) + if(!app.sendMessage(QLatin1String("MSG_SHOWSETTINGS"))) { return -1; + } return 0; } else { if (!QSystemTrayIcon::isSystemTrayAvailable()) {