Candidate session management fixes (kde#346768)

epel8
Rex Dieter 10 years ago
parent a9cbfbb003
commit 952e008164

@ -0,0 +1,128 @@
From 62f448faf202a5a174f0e0bb3d3a80f3109d234f Mon Sep 17 00:00:00 2001
From: Stefan Becker <chemobejk@gmail.com>
Date: Sat, 9 May 2015 17:16:27 +0300
Subject: [PATCH] Add 2nd variant for KConfigGui::sessionConfig()
When application receives a saveState signal it needs to get a KConfig
object based on the QSessionManager information. Add a new variant that
accepts the session manager object.
BUG: 346768
---
src/gui/kconfiggui.cpp | 48 ++++++++++++++++++++++++++++++++++++++----------
src/gui/kconfiggui.h | 14 +++++++++++++-
2 files changed, 51 insertions(+), 11 deletions(-)
diff --git a/src/gui/kconfiggui.cpp b/src/gui/kconfiggui.cpp
index 0048c60..e1dcd09 100644
--- a/src/gui/kconfiggui.cpp
+++ b/src/gui/kconfiggui.cpp
@@ -22,19 +22,52 @@
#include "kconfiggui.h"
#include <QGuiApplication>
+#include <QSessionManager>
#include <kconfig.h>
+#define SESSION_TEMPLATE(id, key) \
+ QLatin1String("session/") + QGuiApplication::applicationName() + \
+ QLatin1Char('_') + (id) + \
+ QLatin1Char('_') + (key)
+
static KConfig *s_sessionConfig = Q_NULLPTR;
-KConfig *KConfigGui::sessionConfig()
+static void ensureSessionConfig(void)
{
- if (!s_sessionConfig) { // create an instance specific config object
- s_sessionConfig = new KConfig(sessionConfigName(), KConfig::SimpleConfig);
+#ifdef QT_NO_SESSIONMANAGER
+#error QT_NO_SESSIONMANAGER was set, this will not compile. Reconfigure Qt with Session management support.
+#endif
+ if (s_sessionConfig == Q_NULLPTR) {
+ // create an instance specific config object
+ s_sessionConfig = new KConfig(SESSION_TEMPLATE(qApp->sessionId(),
+ qApp->sessionKey()),
+ KConfig::SimpleConfig);
}
+}
+
+KConfig *KConfigGui::sessionConfig()
+{
+ ensureSessionConfig();
return s_sessionConfig;
}
+KConfig *KConfigGui::sessionConfig(const QSessionManager &sm)
+{
+ if (hasSessionConfig()) {
+ // delete old config object without storing it to disk
+ s_sessionConfig->markAsClean();
+ delete s_sessionConfig;
+ s_sessionConfig = Q_NULLPTR;
+ }
+
+ // create a new instance specific config object
+ s_sessionConfig = new KConfig(SESSION_TEMPLATE(sm.sessionId(),
+ sm.sessionKey()),
+ KConfig::SimpleConfig);
+ return(s_sessionConfig);
+}
+
bool KConfigGui::hasSessionConfig()
{
return s_sessionConfig != Q_NULLPTR;
@@ -42,11 +75,6 @@ bool KConfigGui::hasSessionConfig()
QString KConfigGui::sessionConfigName()
{
-#ifdef QT_NO_SESSIONMANAGER
-#error QT_NO_SESSIONMANAGER was set, this will not compile. Reconfigure Qt with Session management support.
-#endif
- const QString sessionKey = qApp->sessionKey();
- const QString sessionId = qApp->sessionId();
- return QString(QLatin1String("session/%1_%2_%3")).arg(QGuiApplication::applicationName()).arg(sessionId).arg(sessionKey);
+ ensureSessionConfig();
+ return s_sessionConfig->name();
}
-
diff --git a/src/gui/kconfiggui.h b/src/gui/kconfiggui.h
index 173400f..10083b2 100644
--- a/src/gui/kconfiggui.h
+++ b/src/gui/kconfiggui.h
@@ -27,11 +27,12 @@
#include <QString>
class KConfig;
+class QSessionManager;
namespace KConfigGui
{
/**
- * Returns the application session config object.
+ * Returns the current application session config object.
*
* @return A pointer to the application's instance specific
* KConfig object.
@@ -40,6 +41,17 @@ namespace KConfigGui
KCONFIGGUI_EXPORT KConfig *sessionConfig();
/**
+ * Updates application session config object.
+ *
+ * @param sm session manager object
+ *
+ * @return A pointer to the application's instance specific
+ * KConfig object.
+ * @see KConfig
+ */
+KCONFIGGUI_EXPORT KConfig *sessionConfig(const QSessionManager &sm);
+
+/**
* Indicates if a session config has been created for that application
* (ie. if sessionConfig() got called at least once)
*
--
2.4.0

@ -2,7 +2,7 @@
Name: kf5-%{framework} Name: kf5-%{framework}
Version: 5.9.0 Version: 5.9.0
Release: 2%{?dist} Release: 3%{?dist}
Summary: KDE Frameworks 5 Tier 1 addon with advanced configuration system Summary: KDE Frameworks 5 Tier 1 addon with advanced configuration system
License: GPLv2+ and LGPLv2+ and MIT License: GPLv2+ and LGPLv2+ and MIT
@ -17,6 +17,11 @@ URL: http://www.kde.org
%endif %endif
Source0: http://download.kde.org/%{stable}/frameworks/%{versiondir}/%{framework}-%{version}.tar.xz Source0: http://download.kde.org/%{stable}/frameworks/%{versiondir}/%{framework}-%{version}.tar.xz
## upstreamable patches
# Candidate session management fixes
# https://bugs.kde.org/show_bug.cgi?id=346768
Patch50: Add-2nd-variant-for-KConfigGui_sessionConfig.patch
BuildRequires: kf5-rpm-macros BuildRequires: kf5-rpm-macros
BuildRequires: extra-cmake-modules BuildRequires: extra-cmake-modules
BuildRequires: qt5-qtbase-devel BuildRequires: qt5-qtbase-devel
@ -60,7 +65,7 @@ their changes to their respective configuration files.
%prep %prep
%setup -q -n %{framework}-%{version} %autosetup -n %{framework}-%{version} -p1
%build %build
@ -109,6 +114,9 @@ make install/fast DESTDIR=%{buildroot} -C %{_target_platform}
%changelog %changelog
* Sat May 09 2015 Rex Dieter <rdieter@fedoraproject.org> 5.9.0-3
- Candidate session management fixes (kde#346768)
* Wed Apr 15 2015 Rex Dieter <rdieter@fedoraproject.org> - 5.9.0-2 * Wed Apr 15 2015 Rex Dieter <rdieter@fedoraproject.org> - 5.9.0-2
- -core: Requires: kde-settings - -core: Requires: kde-settings
- .spec cosmetics - .spec cosmetics

Loading…
Cancel
Save