git » kxmlgui.git » commit e463a9f

Fix session restore for KF5 applications (KDEBUG#346768)

author Antonio Rojas
2015-05-16 07:47:08 UTC
committer Antonio Rojas
2015-05-16 07:47:08 UTC
parent d9dd461f1662ae9be26a949eed136cc3470097f8

Fix session restore for KF5 applications (KDEBUG#346768)

PKGBUILD +9 -3
session-restore.patch +54 -0

diff --git a/PKGBUILD b/PKGBUILD
index fd96adf..96712b7 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -3,7 +3,7 @@
 
 pkgname=kxmlgui
 pkgver=5.10.0
-pkgrel=1
+pkgrel=2
 pkgdesc='User configurable main windows'
 arch=('i686' 'x86_64')
 url='https://projects.kde.org/projects/frameworks/kxmlgui'
@@ -11,11 +11,17 @@ license=('LGPL')
 depends=('kglobalaccel' 'ktextwidgets' 'attica-qt5')
 makedepends=('extra-cmake-modules' 'python')
 groups=('kf5')
-source=("http://download.kde.org/stable/frameworks/${pkgver%.*}/${pkgname}-${pkgver}.tar.xz")
-md5sums=('35b8161e519fc6a2a466330a9f24c05f')
+source=("http://download.kde.org/stable/frameworks/${pkgver%.*}/${pkgname}-${pkgver}.tar.xz" 
+'session-restore.patch')
+md5sums=('35b8161e519fc6a2a466330a9f24c05f'
+         '4dc0c7ec892840d27cacb99085219991')
 
 prepare() {
   mkdir -p build
+
+# Fix session restore for KF5 applications https://bugs.kde.org/show_bug.cgi?id=346768
+  cd $pkgname-$pkgver
+  patch -p1 -i "$srcdir"/session-restore.patch
 }
 
 build() {
diff --git a/session-restore.patch b/session-restore.patch
new file mode 100644
index 0000000..409e496
--- /dev/null
+++ b/session-restore.patch
@@ -0,0 +1,54 @@
+From: Stefan Becker <chemobejk@gmail.com>
+Date: Sat, 09 May 2015 14:17:25 +0000
+Subject: Add session management for KMainWindow
+X-Git-Url: http://quickgit.kde.org/?p=kxmlgui.git&a=commitdiff&h=fa86f6e4afd4a4f32d297f271d3daececc6c0ba4
+---
+Add session management for KMainWindow
+
+- replace the KConfig object in KConfigGui with a new one using the
+session id and key from the QSessionManager object
+- make sure that the data is stored after the application has update it
+- if the KConfig object is represented by a local file then add a
+discard command to the session manager object
+
+BUG: 346768
+REVIEW: 123706
+---
+
+
+--- a/src/kmainwindow.cpp
++++ b/src/kmainwindow.cpp
+@@ -127,8 +127,10 @@
+ {
+ }
+ 
+-bool KMWSessionManager::saveState(QSessionManager &)
+-{
++bool KMWSessionManager::saveState(QSessionManager &sm)
++{
++    KConfigGui::setSessionConfig(sm.sessionId(), sm.sessionKey());
++
+     KConfig *config = KConfigGui::sessionConfig();
+     if (KMainWindow::memberList().count()) {
+         // According to Jochen Wilhelmy <digisnap@cs.tu-berlin.de>, this
+@@ -144,6 +146,19 @@
+ 
+     KConfigGroup group(config, "Number");
+     group.writeEntry("NumberOfWindows", n);
++
++    // store new status to disk
++    config->sync();
++
++    // generate discard command for new file
++    QString localFilePath =  QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + config->name();
++    if (QFile::exists(localFilePath)) {
++        QStringList discard;
++        discard << QLatin1String("rm");
++        discard << localFilePath;
++        sm.setDiscardCommand(discard);
++    }
++
+     return true;
+ }
+ 
+