From 2db01ed40e278c2d4e90c9842b0fa88347d4d98c Mon Sep 17 00:00:00 2001
From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com>
Date: Tue, 17 Mar 2020 12:14:54 -0400
Subject: [PATCH] runguard: fix the issue that the app cannot be shown when the
 second instance runs

Change-Id: I764085eaf2cd1613fda738f28a510dcbef71ab0b
---
 src/main.cpp | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/main.cpp b/src/main.cpp
index 4ab402f..7dd2eaa 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -33,21 +33,22 @@ main(int argc, char* argv[])
 
     MainApplication::applicationInitialization();
 
+    char ARG_DISABLE_WEB_SECURITY[] = "--disable-web-security";
+    auto newArgv = MainApplication::parseInputArgument(argc, argv, ARG_DISABLE_WEB_SECURITY);
+
+    MainApplication a(argc, newArgv);
+
     // runguard to make sure that only one instance runs at a time
+    // Note: needs to be after the creation of the application
     QCryptographicHash appData(QCryptographicHash::Sha256);
     appData.addData(QApplication::applicationName().toUtf8());
     appData.addData(QApplication::organizationDomain().toUtf8());
     RunGuard guard(appData.result());
     if (!guard.tryToRun()) {
         // no need to exitApp since app is not set up
-        guard.release();
         return 0;
     }
 
-    char ARG_DISABLE_WEB_SECURITY[] = "--disable-web-security";
-    auto newArgv = MainApplication::parseInputArgument(argc, argv, ARG_DISABLE_WEB_SECURITY);
-
-    MainApplication a(argc, newArgv);
     if (!a.applicationSetup()) {
         guard.release();
         a.exitApp();
-- 
GitLab