Mercurial > hg > syntilista
view src/runguard.h @ 257:f65e0de45c2b
Rename the MinGW cross-build Makefile as it is no longer win32 only.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 05 Dec 2019 03:17:24 +0200 |
parents | 37d5f4329449 |
children |
line wrap: on
line source
// // Taken and modified from https://stackoverflow.com/questions/5006547/qt-best-practice-for-a-single-instance-app-protection // #ifndef RUNGUARD_H #define RUNGUARD_H #include <QObject> #include <QSharedMemory> #include <QSystemSemaphore> class RunGuard { public: RunGuard(const QString &key); ~RunGuard(); bool isAnotherRunning(); bool tryToRun(); void release(); private: const QString key; const QString memLockKey; const QString sharedmemKey; QSharedMemory sharedMem; QSystemSemaphore memLock; Q_DISABLE_COPY(RunGuard) }; #endif // RUNGUARD_H