From 64355e2a3d63a6d38c5600b29f2ee4ee8b618bea Mon Sep 17 00:00:00 2001 From: nowrep Date: Tue, 25 Dec 2012 16:56:23 +0100 Subject: [PATCH] Qt4: Fixed broken session restoring. Adding Qt version into sessionVersion number only when using Qt 5. Closes #689 --- src/lib/app/mainapplication.cpp | 3 +++ src/lib/app/qz_namespace.h | 4 ++-- src/lib/session/restoremanager.cpp | 6 ++++++ src/lib/session/restoremanager.h | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index 6fd8fd240..183166321 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -269,6 +269,9 @@ MainApplication::MainApplication(int &argc, char** argv) } if (m_startingAfterCrash || afterLaunch == 3) { m_restoreManager = new RestoreManager(m_activeProfil + "session.dat"); + if (!m_restoreManager->isValid()) { + destroyRestoreManager(); + } } } diff --git a/src/lib/app/qz_namespace.h b/src/lib/app/qz_namespace.h index 42f36634d..4c0e961b6 100644 --- a/src/lib/app/qz_namespace.h +++ b/src/lib/app/qz_namespace.h @@ -30,9 +30,9 @@ namespace Qz { // Version of session.dat file #if QT_VERSION >= 0x050000 -static const int sessionVersion = 0x0003 & 0x050000; +static const int sessionVersion = 0x0003 | 0x050000; #else -static const int sessionVersion = 0x0003 & 0x040000; +static const int sessionVersion = 0x0003; #endif enum AppMessageType { diff --git a/src/lib/session/restoremanager.cpp b/src/lib/session/restoremanager.cpp index 3c8fe23bf..9b267c87d 100644 --- a/src/lib/session/restoremanager.cpp +++ b/src/lib/session/restoremanager.cpp @@ -30,6 +30,11 @@ RestoreData RestoreManager::restoreData() const return m_data; } +bool RestoreManager::isValid() const +{ + return !m_data.isEmpty(); +} + void RestoreManager::createFromFile(const QString &file) { if (!QFile::exists(file)) { @@ -42,6 +47,7 @@ void RestoreManager::createFromFile(const QString &file) int version; stream >> version; + if (version != Qz::sessionVersion) { return; } diff --git a/src/lib/session/restoremanager.h b/src/lib/session/restoremanager.h index 0444d76af..ca33e010a 100644 --- a/src/lib/session/restoremanager.h +++ b/src/lib/session/restoremanager.h @@ -34,6 +34,7 @@ public: RestoreManager(const QString &sessionFile); QList restoreData() const; + bool isValid() const; private: void createFromFile(const QString &file);