Commit 73191cdc authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

unify signal handling for KWrite & Kate

install the signal handler after application startup, the quit()
will only make sense if we arrive at the exec anyway

use the application as context object, if that is already
dead we shutdown and can just ignore the stuff

make kateshared plublic to be able to use the target include
directory for unit tests, too
parent 18514b37
Pipeline #144169 passed with stage
in 2 minutes and 22 seconds
......@@ -19,7 +19,6 @@ target_include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/qtsingleapplication
${CMAKE_CURRENT_SOURCE_DIR}/quickopen
${CMAKE_CURRENT_BINARY_DIR} # katetests_export.h + config.h
${CMAKE_SOURCE_DIR}/shared
)
find_package(
......@@ -44,7 +43,6 @@ target_link_libraries(
KF5::DBusAddons
KF5::Crash
KF5::TextWidgets
PRIVATE
kateshared
)
......
......@@ -99,21 +99,6 @@ int main(int argc, char **argv)
QApplication app(argc, argv);
#endif
#ifdef Q_OS_UNIX
/**
* Set up signal handler for SIGINT and SIGTERM
*/
SignalWatcher sigWatcher;
QObject::connect(&sigWatcher, &SignalWatcher::unixSignal, [](SignalWatcher::Signal) {
printf("Shutting down...\n");
auto app = KateApp::self();
if (app) {
app->shutdownKate(app->activeKateMainWindow());
}
qApp->quit();
});
#endif
/**
* For Windows and macOS: use Breeze if available
* Of all tested styles that works the best for us
......@@ -712,6 +697,17 @@ 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
*/
......
......@@ -3,7 +3,6 @@ add_executable(kwrite "")
configure_file(config.h.in config.h)
target_include_directories(kwrite PRIVATE
${CMAKE_CURRENT_BINARY_DIR} # config.h
${CMAKE_SOURCE_DIR}/shared
)
find_package(
......@@ -25,6 +24,7 @@ target_link_libraries(
KF5::TextEditor
KF5::DBusAddons
KF5::Crash
kateshared
)
if(KF5Activities_FOUND)
......
......@@ -28,6 +28,7 @@
#include <QTextCodec>
#include <QUrlQuery>
#include <signal_watcher.h>
#include <urlinfo.h>
#ifndef Q_OS_WIN
......@@ -341,6 +342,17 @@ 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, &kapp, [&kapp](SignalWatcher::Signal) {
printf("Shutting down...\n");
kapp.quit();
});
#endif
/**
* Run the event loop
*/
......
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