From: Manuel Nickschas Date: Thu, 22 Jan 2009 21:16:08 +0000 (+0100) Subject: Well, if we check for a settings version, maybe we should set it too... X-Git-Tag: 0.4.0~178 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=015de4656bebd990317b82d8cc993fdc63709f01 Well, if we check for a settings version, maybe we should set it too... --- diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 722be0e9..f832f776 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -22,6 +22,8 @@ #include "settings.h" +const int VERSION = 1; + QHash > Settings::settingsCache; QHash > Settings::settingsChangeNotifier; @@ -61,6 +63,18 @@ void Settings::notify(const QString &key, QObject *receiver, const char *slot) { receiver, slot); } +uint Settings::version() { + // we don't cache this value, and we ignore the group + create_qsettings; + uint ver = s.value("Config/Version", 0).toUInt(); + if(!ver) { + // No version, so create one + s.setValue("Config/Version", VERSION); + return VERSION; + } + return ver; +} + QStringList Settings::allLocalKeys() { create_qsettings; s.beginGroup(group); diff --git a/src/common/settings.h b/src/common/settings.h index 627cb8ab..26c8ead0 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -45,6 +45,7 @@ public: public: virtual void notify(const QString &key, QObject *receiver, const char *slot); + virtual uint version(); protected: inline Settings(QString group_, QString appName_) : group(group_), appName(appName_) {} diff --git a/src/core/core.cpp b/src/core/core.cpp index 9c92faf1..38272e3e 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -71,7 +71,7 @@ Core::Core() : storage(0) { QSettings newSettings(newFilePath, format); #endif /* Q_WS_MAC */ - if(newSettings.value("Config/Version").toUInt() != 1) { + if(newSettings.value("Config/Version").toUInt() == 0) { qWarning() << "\n\n*** IMPORTANT: Config and data file locations have changed. Attempting to auto-migrate your core settings..."; # ifdef Q_WS_MAC QString org = "quassel-irc.org"; @@ -122,6 +122,14 @@ Core::Core() : storage(0) { #endif /* !Q_WS_MAC */ // MIGRATION end + // check settings version + // so far, we only have 1 + CoreSettings s; + if(s.version() != 1) { + qCritical() << "Invalid core settings version, terminating!"; + exit(EXIT_FAILURE); + } + // Register storage backends here! registerStorageBackend(new SqliteStorage(this)); diff --git a/src/qtui/qtuiapplication.cpp b/src/qtui/qtuiapplication.cpp index 0c7f9220..8acead9a 100644 --- a/src/qtui/qtuiapplication.cpp +++ b/src/qtui/qtuiapplication.cpp @@ -29,6 +29,7 @@ #include "client.h" #include "cliparser.h" #include "qtui.h" +#include "qtuisettings.h" #include "sessionsettings.h" QtUiApplication::QtUiApplication(int &argc, char **argv) @@ -81,7 +82,7 @@ bool QtUiApplication::init() { QSettings newSettings(newFilePath, format); #endif /* Q_WS_MAC */ - if(newSettings.value("Config/Version").toUInt() != 1) { + if(newSettings.value("Config/Version").toUInt() == 0) { qWarning() << "\n\n*** IMPORTANT: Config and data file locations have changed. Attempting to auto-migrate your client settings..."; # ifdef Q_WS_MAC QString org = "quassel-irc.org"; @@ -100,6 +101,14 @@ bool QtUiApplication::init() { // MIGRATION end + // check settings version + // so far, we only have 1 + QtUiSettings s; + if(s.version() != 1) { + qCritical() << "Invalid client settings version, terminating!"; + return false; + } + // session resume QtUi *gui = new QtUi(); Client::init(gui);