From a34adf5990d3e1ee22c858e431383ef5998ab409 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sat, 18 Feb 2017 14:34:30 +0200 Subject: [PATCH] fix #171,use lock file instead of QSharedMemory -- this way the lock is per user and crashing Latte allows us to rerun it properly --- app/main.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index 3c91c2144..5796e54d5 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include #include @@ -54,13 +56,12 @@ void noMessageOutput(QtMsgType type, const QMessageLogContext &context, const QS int main(int argc, char **argv) { - QSharedMemory sharedMemory; - sharedMemory.setKey("latte-dock"); + QString tmpDir = QDir::tempPath(); + QLockFile lockFile(tmpDir + "/latte-dock.lock"); - if (!sharedMemory.create(1)) { + if (!lockFile.tryLock(100)) { qDebug() << i18n("Warning: An instance of Latte application is already running!!!"); - - exit(0); // Exit, already a process running + exit(0); } // Devive pixel ratio has some problems in latte (plasmashell) currently.