[Pkg-owncloud-commits] [owncloud-client] 171/218: Linux: Don't show settings dialog always when launched twice

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 17 14:31:05 UTC 2015


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 641dece89a7080d0c1db2b28fe53145a6e8b9305
Author: Markus Goetz <markus at woboq.com>
Date:   Mon Sep 28 22:51:16 2015 +0200

    Linux: Don't show settings dialog always when launched twice
    
    For #3273 #3771 #3485
    See also d503221b2e22109eb9f2a3d875dcd247dd8b4cf9
---
 src/gui/application.cpp | 8 ++++++++
 src/gui/application.h   | 3 +++
 src/gui/main.cpp        | 4 +++-
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/gui/application.cpp b/src/gui/application.cpp
index a8b3929..3e5148a 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 7a246e6..5381209 100644
--- a/src/gui/application.h
+++ b/src/gui/application.h
@@ -19,6 +19,7 @@
 #include <QPointer>
 #include <QQueue>
 #include <QTimer>
+#include <QElapsedTimer>
 
 #include "qtsingleapplication.h"
 
@@ -97,6 +98,8 @@ private:
     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 49cd4af..83c3806 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()) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list