Commit 4e732051 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(App): quit properly on SIGINT

parent 485a9f3e
......@@ -72,6 +72,8 @@ public:
bool hasFocus () const;
void quit () override;
static App *getInstance () {
return static_cast<App *>(QApplication::instance());
}
......@@ -85,9 +87,6 @@ public:
Q_INVOKABLE static void smartShowWindow (QQuickWindow *window);
public slots:
void quit ();
signals:
void configLocaleChanged (const QString &locale);
......
......@@ -251,16 +251,16 @@ void SingleApplicationPrivate::connectToPrimary (int msecs, char connectionType)
}
void SingleApplicationPrivate::terminate (int signum) {
if (signum == SIGINT) {
SingleApplication::instance()->quit();
return;
}
while (!sharedMem.empty()) {
delete sharedMem.back();
sharedMem.pop_back();
}
cout << "[PROCESS ABNORMALLY TERMINATED]: " << signum << endl;
#ifdef Q_OS_LINUX
cout << "If you have used valgrind, please remove your ~/.ICEauthority file and rerun." << endl;
#endif // ifdef Q_OS_UNIX
::exit(128 + signum);
}
......@@ -453,3 +453,7 @@ bool SingleApplication::sendMessage (QByteArray message, int timeout) {
d->socket->waitForBytesWritten(timeout);
return dataWritten;
}
void SingleApplication::quit () {
QCoreApplication::quit();
}
......@@ -112,6 +112,8 @@ public:
*/
bool sendMessage (QByteArray message, int timeout = 100);
virtual void quit ();
Q_SIGNALS:
void instanceStarted ();
void receivedMessage (quint32 instanceId, QByteArray message);
......
......@@ -119,3 +119,7 @@ void SingleApplicationPrivate::messageReceived (quint32 instanceId, QByteArray m
Q_Q(SingleApplication);
Q_EMIT q->receivedMessage(instanceId, message);
}
void SingleApplication::quit () {
QCoreApplication::quit();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment