Index: src/kmainwindow.cpp =================================================================== --- src/kmainwindow.cpp +++ src/kmainwindow.cpp @@ -174,10 +174,7 @@ /* Purpose of this exercise: invoke queryClose() without actually closing the - windows, because - - queryClose() may contain session management code, so it must be invoked - - actually closing windows may quit the application - cf. - QGuiApplication::quitOnLastWindowClosed() + application, because - quitting the application and thus closing the session manager connection violates the X11 XSMP protocol. The exact requirement of XSMP that would be broken is, @@ -189,18 +186,18 @@ Worst of all, that is a real problem with ksmserver - it will not save applications that quit on their own in state save-yourself-done. */ + QGuiApplication::setQuitOnLastWindowClosed(false); const auto windows = KMainWindow::memberList(); for (KMainWindow *window : windows) { if (window->testAttribute(Qt::WA_WState_Hidden)) { continue; } - QCloseEvent e; - QApplication::sendEvent(window, &e); - if (!e.isAccepted()) { + if (!window->close()) { sm.cancel(); - return; + break; } } + QGuiApplication::setQuitOnLastWindowClosed(true); } Q_GLOBAL_STATIC(KMWSessionManager, ksm)