aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 2b1837a..f907e6a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -44,6 +44,25 @@
int main(int argc, char *argv[]) {
qDebug() << "This app was built on: " << BUILD_TIME;
+ // We don't want users to have multiple instances of this app running
+ QString tmpDirPath = QDir::tempPath() + "/rwa.support.desktopapp";
+ QString tmpFilePath = tmpDirPath + "/prevent-multiple-instances.lock";
+ QDir tmpDir(tmpDirPath);
+ if (!tmpDir.exists()) {
+ // Ensure that the path exists
+ tmpDir.mkpath(".");
+ }
+ QLockFile lockFile(tmpFilePath);
+ qDebug() << "Checking for a lockfile at: " + tmpFilePath;
+
+ if(!lockFile.tryLock(100)){
+ qDebug() << QObject::tr("You already have this app running.");
+ qDebug() << QObject::tr("Only one instance is allowed.");
+ qDebug() << QObject::tr("Closing application now with an error.");
+
+ return 1;
+ }
+
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
@@ -82,24 +101,5 @@ int main(int argc, char *argv[]) {
engine.rootObjects().takeFirst(),
SLOT(showWindow()));
- // We don't want users to have multiple instances of this app running
- QString tmpDirPath = QDir::tempPath() + "/rwa.support.desktopapp";
- QString tmpFilePath = tmpDirPath + "/prevent-multiple-instances.lock";
- QDir tmpDir(tmpDirPath);
- if (!tmpDir.exists()) {
- // Ensure that the path exists
- tmpDir.mkpath(".");
- }
- QLockFile lockFile(tmpFilePath);
- qDebug() << "Checking for a lockfile at: " + tmpFilePath;
-
- if(!lockFile.tryLock(100)){
- qDebug() << QObject::tr("You already have this app running.");
- qDebug() << QObject::tr("Only one instance is allowed.");
- qDebug() << QObject::tr("Closing application now with an error.");
-
- return 1;
- }
-
return app.exec();
}