-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
30 lines (23 loc) · 691 Bytes
/
Copy pathmain.cpp
File metadata and controls
30 lines (23 loc) · 691 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "mainwindow.h"
#include <QApplication>
#include <QSharedMemory>
#include <QMessageBox>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// Single instance check
QSharedMemory sharedMemory("InstagramTaskerSingleInstance");
if (!sharedMemory.create(1)) {
if (sharedMemory.attach()) {
sharedMemory.detach();
}
QMessageBox::warning(nullptr, "Already Running", "InstagramTasker is already running.");
return 1;
}
MainWindow w;
// w.show(); // Comment out to start minimized to tray
int result = a.exec();
// Detach shared memory on exit
sharedMemory.detach();
return result;
}