Giter Site home page Giter Site logo

Comments (5)

Mart-Bogdan avatar Mart-Bogdan commented on June 16, 2024

P.S. IDK why it has bug label, but I wasn't able to change labels upon issue creation.

from kdiskmark.

Mart-Bogdan avatar Mart-Bogdan commented on June 16, 2024

Would it be ok for me to create PR with something along this lines:

diff --git a/src/main.cpp b/src/main.cpp
index e300159..422d6c8 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -5,6 +5,8 @@
 #include "singleapplication.h"
 #include "cmake.h"
 
+bool use_multi_instance(int argc, char *argv[]);
+
 int main(int argc, char *argv[])
 {
     QCoreApplication::setApplicationName(QStringLiteral(PROJECT_NAME));
@@ -13,7 +15,12 @@ int main(int argc, char *argv[])
 
     QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
 
-    SingleApplication a(argc, argv);
+    std::unique_ptr<QApplication> a;
+    if (use_multi_instance(argc, argv)) {
+        a = std::make_unique<QApplication>(argc, argv);
+    } else {
+        a = std::make_unique<SingleApplication>(argc, argv);
+    }
 
     AppSettings().setupLocalization();
 
@@ -21,5 +28,17 @@ int main(int argc, char *argv[])
     w.setFixedSize(w.size());
     w.show();
 
-    return a.exec();
+    return a->exec();
 }
+
+const std::string MULTI_INSTANCE_ARG = "--multi-instance";
+
+bool use_multi_instance(int argc, char *argv[])
+{
+    for (int i = 0; i < argc; ++i) {
+        if (argv[i] == MULTI_INSTANCE_ARG) {
+            return true;
+        }
+    }
+    return false;
+}
\ No newline at end of file

Command swith to be decided. And sorry for code stype. I've have to look at style used across the project etc.

But that's just a a sketch.

As I understand: before we created QApplication instance we can't use Qt's facility to parse arguments, so have to do it manually.

from kdiskmark.

Mart-Bogdan avatar Mart-Bogdan commented on June 16, 2024

Turns out this solution is better:

diff --git a/src/main.cpp b/src/main.cpp
index e300159..872bb6d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -5,6 +5,8 @@
 #include "singleapplication.h"
 #include "cmake.h"
 
+bool use_multi_instance(int argc, char *argv[]);
+
 int main(int argc, char *argv[])
 {
     QCoreApplication::setApplicationName(QStringLiteral(PROJECT_NAME));
@@ -13,7 +15,7 @@ int main(int argc, char *argv[])
 
     QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
 
-    SingleApplication a(argc, argv);
+    SingleApplication a(argc, argv, use_multi_instance(argc, argv));
 
     AppSettings().setupLocalization();
 
@@ -23,3 +25,15 @@ int main(int argc, char *argv[])
 
     return a.exec();
 }
+
+const std::string MULTI_INSTANCE_ARG = "--multi-instance";
+
+bool use_multi_instance(int argc, char *argv[])
+{
+    for (int i = 0; i < argc; ++i) {
+        if (argv[i] == MULTI_INSTANCE_ARG) {
+            return true;
+        }
+    }
+    return false;
+}
\ No newline at end of file

from kdiskmark.

Mart-Bogdan avatar Mart-Bogdan commented on June 16, 2024

I jsut got thought. Would this create problems with helper?

from kdiskmark.

JonMagon avatar JonMagon commented on June 16, 2024

I jsut got thought. Would this create problems with helper?

This can cause problems when running simultaneous tests. But the flag idea is a good one.

from kdiskmark.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.