comparison 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
comparison
equal deleted inserted replaced
227:07e7f254ef16 228:37d5f4329449
13 #include "main.h" 13 #include "main.h"
14 #include "ui_mainwindow.h" 14 #include "ui_mainwindow.h"
15 #include "ui_editperson.h" 15 #include "ui_editperson.h"
16 #include "ui_aboutwindow.h" 16 #include "ui_aboutwindow.h"
17 #include "ui_viewtransactions.h" 17 #include "ui_viewtransactions.h"
18 #include "runguard.h"
18 19
19 20
20 // 21 //
21 // Application settings struct 22 // Application settings struct
22 // 23 //
259 // 260 //
260 int main(int argc, char *argv[]) 261 int main(int argc, char *argv[])
261 { 262 {
262 QApplication sapp(argc, argv); 263 QApplication sapp(argc, argv);
263 QSettings tmpst(APP_VENDOR, APP_ID); 264 QSettings tmpst(APP_VENDOR, APP_ID);
265
266 // Check for multiple instances
267 RunGuard guard(QStringLiteral(APP_VENDOR) + QStringLiteral(APP_ID));
268 if (!guard.tryToRun())
269 {
270 slErrorMsg(
271 QObject::tr("Virhe!"),
272 QObject::tr(
273 "Syntilista-sovellus on jo käynnissä. Sulje tämä ikkuna ja "
274 "etsi ajossa oleva Syntilista-sovellus tehtäväpalkista."
275 )
276 );
277 return 1;
278 }
264 279
265 // Read configuration settings 280 // Read configuration settings
266 settings.uiPos = tmpst.value("pos", QPoint(100, 100)).toPoint(); 281 settings.uiPos = tmpst.value("pos", QPoint(100, 100)).toPoint();
267 settings.uiSize = tmpst.value("size", QSize(1000, 600)).toSize(); 282 settings.uiSize = tmpst.value("size", QSize(1000, 600)).toSize();
268 settings.uiScale = tmpst.value("scale", 1.0f).toDouble(); 283 settings.uiScale = tmpst.value("scale", 1.0f).toDouble();