This commit is contained in:
parent
2755c48f45
commit
420fd8a179
@ -1,8 +1,32 @@
|
|||||||
|
From f7cbcc77722256db084d3b0ab6ce76173e959f0e Mon Sep 17 00:00:00 2001
|
||||||
|
From: Andreas Hartmetz <ahartmetz@gmail.com>
|
||||||
|
Date: Fri, 19 Feb 2016 19:37:36 +0100
|
||||||
|
Subject: [PATCH 1/1] Fix session management broken since KF5 / Qt5.
|
||||||
|
|
||||||
|
Requires Qt 5.6 branch not more than a few days old, or >= 5.6.0
|
||||||
|
when it is released.
|
||||||
|
Parts of the fix are:
|
||||||
|
- Call QGuiApplication::setFallbackSessionManagementEnabled(false)
|
||||||
|
to prevent application suicide through a mechanism that tries to
|
||||||
|
help applications without any proper session management support,
|
||||||
|
but badly interferes with applications that do implement proper
|
||||||
|
session management, such as KDE applications.
|
||||||
|
- Add back commitData[Request] handling. For some reason it was
|
||||||
|
removed during porting.
|
||||||
|
- Change the returned types of saveState() and commitData() to void.
|
||||||
|
The return values were unused.
|
||||||
|
|
||||||
|
BUG: 354724
|
||||||
|
---
|
||||||
|
src/kmainwindow.cpp | 44 +++++++++++++++++++++++++++++++++++++++++---
|
||||||
|
src/kmainwindow_p.h | 3 ++-
|
||||||
|
2 files changed, 43 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
diff --git a/src/kmainwindow.cpp b/src/kmainwindow.cpp
|
diff --git a/src/kmainwindow.cpp b/src/kmainwindow.cpp
|
||||||
index cae655d..7455132 100644
|
index cae655d..c384b67 100644
|
||||||
--- a/src/kmainwindow.cpp
|
--- a/src/kmainwindow.cpp
|
||||||
+++ b/src/kmainwindow.cpp
|
+++ b/src/kmainwindow.cpp
|
||||||
@@ -121,14 +121,18 @@ KMWSessionManager::KMWSessionManager()
|
@@ -121,13 +121,15 @@ KMWSessionManager::KMWSessionManager()
|
||||||
{
|
{
|
||||||
connect(qApp, SIGNAL(saveStateRequest(QSessionManager&)),
|
connect(qApp, SIGNAL(saveStateRequest(QSessionManager&)),
|
||||||
this, SLOT(saveState(QSessionManager&)));
|
this, SLOT(saveState(QSessionManager&)));
|
||||||
@ -17,12 +41,9 @@ index cae655d..7455132 100644
|
|||||||
-bool KMWSessionManager::saveState(QSessionManager &sm)
|
-bool KMWSessionManager::saveState(QSessionManager &sm)
|
||||||
+void KMWSessionManager::saveState(QSessionManager &sm)
|
+void KMWSessionManager::saveState(QSessionManager &sm)
|
||||||
{
|
{
|
||||||
+ sm.setAutoCloseWindowsEnabled(false);
|
|
||||||
+
|
|
||||||
KConfigGui::setSessionConfig(sm.sessionId(), sm.sessionKey());
|
KConfigGui::setSessionConfig(sm.sessionId(), sm.sessionKey());
|
||||||
|
|
||||||
KConfig *config = KConfigGui::sessionConfig();
|
@@ -158,8 +160,42 @@ bool KMWSessionManager::saveState(QSessionManager &sm)
|
||||||
@@ -158,8 +162,58 @@ bool KMWSessionManager::saveState(QSessionManager &sm)
|
|
||||||
discard << localFilePath;
|
discard << localFilePath;
|
||||||
sm.setDiscardCommand(discard);
|
sm.setDiscardCommand(discard);
|
||||||
}
|
}
|
||||||
@ -31,8 +52,6 @@ index cae655d..7455132 100644
|
|||||||
- return true;
|
- return true;
|
||||||
+void KMWSessionManager::commitData(QSessionManager &sm)
|
+void KMWSessionManager::commitData(QSessionManager &sm)
|
||||||
+{
|
+{
|
||||||
+ // Prevents QGuiApplication::commitData() from closing our windows with tryCloseAllWindows()
|
|
||||||
+ sm.setAutoCloseWindowsEnabled(false);
|
|
||||||
+ if (!sm.allowsInteraction()) {
|
+ if (!sm.allowsInteraction()) {
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
@ -41,8 +60,8 @@ index cae655d..7455132 100644
|
|||||||
+ Purpose of this exercise: invoke queryClose() without actually closing the
|
+ Purpose of this exercise: invoke queryClose() without actually closing the
|
||||||
+ windows, because
|
+ windows, because
|
||||||
+ - queryClose() may contain session management code, so it must be invoked
|
+ - queryClose() may contain session management code, so it must be invoked
|
||||||
+ - closing windows may quit the application
|
+ - actually closing windows may quit the application - cf.
|
||||||
+ (cf. QGuiApplication::quitOnLastWindowClosed())
|
+ QGuiApplication::quitOnLastWindowClosed()
|
||||||
+ - quitting the application and thus closing the session manager connection
|
+ - quitting the application and thus closing the session manager connection
|
||||||
+ violates the X11 XSMP protocol.
|
+ violates the X11 XSMP protocol.
|
||||||
+ The exact requirement of XSMP that would be broken is,
|
+ The exact requirement of XSMP that would be broken is,
|
||||||
@ -51,7 +70,7 @@ index cae655d..7455132 100644
|
|||||||
+ save-yourself-done: (changing state is forbidden)
|
+ save-yourself-done: (changing state is forbidden)
|
||||||
+
|
+
|
||||||
+ Closing the session manager connection causes a state change.
|
+ Closing the session manager connection causes a state change.
|
||||||
+ Worst of all, that is an actual problem with ksmserver - it will not save
|
+ 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.
|
+ applications that quit on their own in state save-yourself-done.
|
||||||
+ */
|
+ */
|
||||||
+ foreach (KMainWindow *window, KMainWindow::memberList()) {
|
+ foreach (KMainWindow *window, KMainWindow::memberList()) {
|
||||||
@ -62,31 +81,23 @@ index cae655d..7455132 100644
|
|||||||
+ QApplication::sendEvent(window, &e);
|
+ QApplication::sendEvent(window, &e);
|
||||||
+ if (!e.isAccepted()) {
|
+ if (!e.isAccepted()) {
|
||||||
+ sm.cancel();
|
+ sm.cancel();
|
||||||
+ break;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+ /* Don't even think_about deleting widgets with
|
|
||||||
+ Qt::WDestructiveClose flag set at this point. We
|
|
||||||
+ are faking a close event, but we are *not*_
|
|
||||||
+ closing the window. The purpose of the faked
|
|
||||||
+ close event is to prepare the application so it
|
|
||||||
+ can safely be quit without the user losing data
|
|
||||||
+ (possibly showing a message box "do you want to
|
|
||||||
+ save this or that?"). It is possible that the
|
|
||||||
+ session manager quits the application later
|
|
||||||
+ (emitting QApplication::aboutToQuit() when this
|
|
||||||
+ happens), but it is also possible that the user
|
|
||||||
+ cancels the shutdown, so the application will
|
|
||||||
+ continue to run.
|
|
||||||
+ */
|
|
||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(KMWSessionManager, ksm)
|
Q_GLOBAL_STATIC(KMWSessionManager, ksm)
|
||||||
@@ -893,4 +947,3 @@ QString KMainWindow::dbusName() const
|
@@ -180,7 +216,9 @@ KMainWindow::KMainWindow(KMainWindowPrivate &dd, QWidget *parent, Qt::WindowFlag
|
||||||
}
|
void KMainWindowPrivate::init(KMainWindow *_q)
|
||||||
|
{
|
||||||
#include "moc_kmainwindow.cpp"
|
q = _q;
|
||||||
-
|
-
|
||||||
|
+#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||||
|
+ QGuiApplication::setFallbackSessionManagementEnabled(false);
|
||||||
|
+#endif
|
||||||
|
q->setAnimated(q->style()->styleHint(QStyle::SH_Widget_Animate, 0, q));
|
||||||
|
|
||||||
|
q->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
diff --git a/src/kmainwindow_p.h b/src/kmainwindow_p.h
|
diff --git a/src/kmainwindow_p.h b/src/kmainwindow_p.h
|
||||||
index 8204ce1..910680d 100644
|
index 8204ce1..910680d 100644
|
||||||
--- a/src/kmainwindow_p.h
|
--- a/src/kmainwindow_p.h
|
||||||
@ -101,3 +112,6 @@ index 8204ce1..910680d 100644
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
--
|
||||||
|
2.6.2
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user