Mercurial > hg > syntilista
diff src/main.cpp @ 228:37d5f4329449
Implement single running instance check to prevent problems with the SQLite database.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 20 Mar 2018 13:45:21 +0200 |
parents | c0dfbbd67692 |
children | e90dba0cd12a |
line wrap: on
line diff
--- a/src/main.cpp Mon Mar 12 10:52:21 2018 +0200 +++ b/src/main.cpp Tue Mar 20 13:45:21 2018 +0200 @@ -15,6 +15,7 @@ #include "ui_editperson.h" #include "ui_aboutwindow.h" #include "ui_viewtransactions.h" +#include "runguard.h" // @@ -262,6 +263,20 @@ QApplication sapp(argc, argv); QSettings tmpst(APP_VENDOR, APP_ID); + // Check for multiple instances + RunGuard guard(QStringLiteral(APP_VENDOR) + QStringLiteral(APP_ID)); + if (!guard.tryToRun()) + { + slErrorMsg( + QObject::tr("Virhe!"), + QObject::tr( + "Syntilista-sovellus on jo käynnissä. Sulje tämä ikkuna ja " + "etsi ajossa oleva Syntilista-sovellus tehtäväpalkista." + ) + ); + return 1; + } + // Read configuration settings settings.uiPos = tmpst.value("pos", QPoint(100, 100)).toPoint(); settings.uiSize = tmpst.value("size", QSize(1000, 600)).toSize();