kwin_wrapper: properly handle SIGTERM signals
QCoreApplication is not signal trap safe, use KSignalHandler to do it properly.
This commit is contained in:
parent
e9db27d05d
commit
52c9eef122
2 changed files with 8 additions and 7 deletions
|
@ -15,6 +15,6 @@ ecm_qt_declare_logging_category(kwin_wayland_wrapper
|
|||
Warning
|
||||
)
|
||||
|
||||
target_link_libraries(kwin_wayland_wrapper Qt5::Core Qt5::DBus KF5::DBusAddons KWinXwaylandCommon)
|
||||
target_link_libraries(kwin_wayland_wrapper Qt5::Core Qt5::DBus KF5::DBusAddons KF5::CoreAddons KWinXwaylandCommon)
|
||||
set_property(TARGET kwin_wayland_wrapper PROPERTY C_STANDARD 11)
|
||||
install(TARGETS kwin_wayland_wrapper ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <QDBusConnection>
|
||||
|
||||
#include <UpdateLaunchEnvironmentJob>
|
||||
#include <KSignalHandler>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
|
@ -156,17 +157,17 @@ void KWinWrapper::run()
|
|||
});
|
||||
}
|
||||
|
||||
void sigtermHandler(int)
|
||||
{
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
app.setQuitLockEnabled(false); // don't exit when the first KJob finishes
|
||||
|
||||
signal(SIGTERM, sigtermHandler);
|
||||
KSignalHandler::self()->watchSignal(SIGTERM);
|
||||
QObject::connect(KSignalHandler::self(), &KSignalHandler::signalReceived, &app, [&app](int signal) {
|
||||
if (signal == SIGTERM) {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
KWinWrapper wrapper(&app);
|
||||
wrapper.run();
|
||||
|
|
Loading…
Reference in a new issue