Commit d5974b85 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

install signal watcher in KateApp

avoid even more code duplication between kwrite & kate
parent c7fa9e55
......@@ -41,6 +41,7 @@
#include <QTextCodec>
#include <QUrlQuery>
#include <signal_watcher.h>
#include <urlinfo.h>
/**
......@@ -132,6 +133,17 @@ bool KateApp::init()
qputenv("KATE_PID", QStringLiteral("%1").arg(QCoreApplication::applicationPid()).toLatin1().constData());
}
#ifdef Q_OS_UNIX
/**
* Set up signal handler for SIGINT and SIGTERM
*/
auto sigWatcher = new SignalWatcher(this);
connect(sigWatcher, &SignalWatcher::unixSignal, this, [this](SignalWatcher::Signal) {
printf("Shutting down...\n");
quit();
});
#endif
// handle restore different
if (qApp->isSessionRestored()) {
restoreKate();
......
......@@ -33,7 +33,6 @@
#include <QUrl>
#include <QVariant>
#include <signal_watcher.h>
#include <urlinfo.h>
#ifdef USE_QT_SINGLE_APP
......@@ -693,17 +692,6 @@ int main(int argc, char **argv)
#endif
#ifdef Q_OS_UNIX
/**
* Set up signal handler for SIGINT and SIGTERM
*/
SignalWatcher sigWatcher;
QObject::connect(&sigWatcher, &SignalWatcher::unixSignal, &kateApp, [&kateApp](SignalWatcher::Signal) {
printf("Shutting down...\n");
kateApp.shutdownKate(kateApp.activeKateMainWindow());
});
#endif
/**
* start main event loop for our application
*/
......
......@@ -28,7 +28,6 @@
#include <QTextCodec>
#include <QUrlQuery>
#include <signal_watcher.h>
#include <urlinfo.h>
#ifndef Q_OS_WIN
......@@ -250,17 +249,6 @@ extern "C" Q_DECL_EXPORT int main(int argc, char **argv)
*/
const KDBusService dbusService(KDBusService::Multiple | KDBusService::NoExitOnFailure);
#ifdef Q_OS_UNIX
/**
* Set up signal handler for SIGINT and SIGTERM
*/
SignalWatcher sigWatcher;
QObject::connect(&sigWatcher, &SignalWatcher::unixSignal, &kateApp, [&kateApp](SignalWatcher::Signal) {
printf("Shutting down...\n");
kateApp.quit();
});
#endif
/**
* Run the event loop
*/
......
Supports Markdown
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