summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Edmundson <davidedmundson@kde.org>2019-02-28 23:47:14 +0000
committerDavid Edmundson <davidedmundson@kde.org>2019-03-01 01:15:43 +0000
commit404bee752c5058506900c23faa9d577a38b300f1 (patch)
tree2401e2c3738deda0f15af3d864a7c1090e9c00ae
parent3b756bdcf52a33c33f5b7aa573912bb6bd70efbe (diff)
Add attribute to disable QSessionManager
Loading a session manager can be problemtatic for system services that are always auto-activated or small DBus activated helpers which shouldn't really be restored nor gain anything from a session. The current solutions is to connect to commitDataRequest and saveStateRequest and then reset a restart hint. It's very unintuitive and somewhat wasteful given the X session manager is full of slow blocking calls. Rather than changing the behavior of QGuiApplication and handling null pointers, this patch loads the base QPlatformSessionManager that is used by QPAs that don't have a session manager. Change-Id: I976521d551549e2d56076e968c6be5421e4a9c20 Reviewed-by: Albert Astals Cid <aacid@kde.org> Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
-rw-r--r--src/corelib/global/qnamespace.h1
-rw-r--r--src/corelib/global/qnamespace.qdoc7
-rw-r--r--src/gui/kernel/qsessionmanager.cpp6
3 files changed, 13 insertions, 1 deletions
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 8b27c60fec..f5f7176670 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -546,6 +546,7 @@ public:
AA_DontShowShortcutsInContextMenus = 28,
AA_CompressTabletEvents = 29,
AA_DisableWindowContextHelpButton = 30, // ### Qt 6: remove me
+ AA_DisableSessionManager = 31,
// Add new attributes before this line
AA_AttributeCount
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 12e09d44e7..45d79902c7 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -286,6 +286,13 @@
This value was added in Qt 5.10. In Qt 6, WindowContextHelpButtonHint
will not be set by default.
+ \value AA_DisableSessionManager Disables the QSessionManager.
+ By default Qt will connect to a running session manager for a GUI
+ application on supported platforms, use of a session manager may be
+ redundant for system services.
+ This attribute must be set before QGuiApplication is constructed.
+ This value was added in 5.13
+
The following values are deprecated or obsolete:
\value AA_ImmediateWidgetCreation This attribute is no longer fully
diff --git a/src/gui/kernel/qsessionmanager.cpp b/src/gui/kernel/qsessionmanager.cpp
index 493a321c74..e5e9c624b2 100644
--- a/src/gui/kernel/qsessionmanager.cpp
+++ b/src/gui/kernel/qsessionmanager.cpp
@@ -123,7 +123,11 @@ QSessionManagerPrivate::QSessionManagerPrivate(const QString &id,
const QString &key)
: QObjectPrivate()
{
- platformSessionManager = QGuiApplicationPrivate::platformIntegration()->createPlatformSessionManager(id, key);
+ if (qApp->testAttribute(Qt::AA_DisableSessionManager)) {
+ platformSessionManager = new QPlatformSessionManager(id, key);
+ } else {
+ platformSessionManager = QGuiApplicationPrivate::platformIntegration()->createPlatformSessionManager(id, key);
+ }
Q_ASSERT_X(platformSessionManager, "Platform session management",
"No platform session management, should use the default implementation");
}