make sure that only one instance of the application runs

This commit is contained in:
Martin Brodbeck 2018-11-07 16:02:07 +01:00
parent 6c51f8cec5
commit 7a8c7a9d0b

View file

@ -7,6 +7,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QSettings> #include <QSettings>
#include <QTranslator> #include <QTranslator>
#include <QSharedMemory>
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
@ -16,6 +17,13 @@ int main(int argc, char* argv[])
QCoreApplication::setOrganizationDomain("rustysoft.de"); QCoreApplication::setOrganizationDomain("rustysoft.de");
QCoreApplication::setApplicationName("kima2"); QCoreApplication::setApplicationName("kima2");
// Make sure that only one instance of the application runs
// Of course the uuid used here is unique to this application
QSharedMemory shared("26297455-946a-4607-bfb7-5025a5f1e136");
if (!shared.create(512, QSharedMemory::ReadWrite)) {
exit(0);
}
QTranslator qTranslator; QTranslator qTranslator;
QLocale german(QLocale::German); QLocale german(QLocale::German);
#ifdef __linux__ #ifdef __linux__