From d79faf5d2e303106f85c02b83dbde8f05929519c Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Fri, 10 May 2024 03:26:40 +0300 Subject: [PATCH] kdeui: do not ask top-level widgets for close twice it could happen because after session management is done klauncher sends SIGTERM to the programs (the session manager does not close the applications) Signed-off-by: Ivailo Monev --- kdeui/kernel/kapplication.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/kdeui/kernel/kapplication.cpp b/kdeui/kernel/kapplication.cpp index ba1b6cab..a1bd89a8 100644 --- a/kdeui/kernel/kapplication.cpp +++ b/kdeui/kernel/kapplication.cpp @@ -84,6 +84,8 @@ static const int s_quit_signals[] = { 0 }; +static QWidgetList s_asked; + static void quit_handler(int sig) { if (!qApp) { @@ -99,6 +101,10 @@ static void quit_handler(int sig) if (!topwidget || !topwidget->isWindow() || !topwidget->inherits("QMainWindow")) { continue; } + if (s_asked.contains(topwidget)) { + kDebug() << "already asked" << topwidget; + continue; + } kDebug() << "closing" << topwidget; if (!topwidget->close()) { kDebug() << "not quiting because a top-level window did not close"; @@ -462,24 +468,18 @@ KConfig* KApplication::sessionConfig() bool KApplication::saveSession() { - foreach (KMainWindow *window, KMainWindow::memberList()) { - if (!window->testAttribute(Qt::WA_WState_Hidden)) { - QCloseEvent e; - QApplication::sendEvent(window, &e); - if (!e.isAccepted()) { - return false; - } - } - } - foreach (QWidget* widget, QApplication::topLevelWidgets()) { - if (!widget || widget->isHidden() || widget->inherits("QMainWindow")) { + s_asked.clear(); + foreach (QWidget* topwidget, QApplication::topLevelWidgets()) { + if (!topwidget || !topwidget->isWindow() || !topwidget->inherits("QMainWindow")) { continue; } QCloseEvent e; - QApplication::sendEvent(widget, &e); + QApplication::sendEvent(topwidget, &e); if (!e.isAccepted()) { + s_asked.clear(); return false; } + s_asked.append(topwidget); } d->session_save = true;