Clarify settings migration logic comments
authorShane Synan <digitalcircuit36939@gmail.com>
Sat, 7 Jan 2017 01:16:31 +0000 (19:16 -0600)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 13 Apr 2017 19:47:30 +0000 (21:47 +0200)
Add comments clarifying use of VERSION_MINOR_CURRENT in
migrateSettings() and the switch statements in
applySettingsMigration().  It's easy enough to do one and miss the
other as they're not very close by.

(I should've commented this in the first place.  Pardon!)

Resolves GH-269.

src/qtui/qtuiapplication.cpp

index 2b6b58c..8120aed 100644 (file)
@@ -210,6 +210,9 @@ bool QtUiApplication::migrateSettings()
     // --------
     // Check minor settings version, handling upgrades/downgrades as needed
     // Current minor version
     // --------
     // Check minor settings version, handling upgrades/downgrades as needed
     // Current minor version
+    //
+    // NOTE:  If you increase the minor version, you MUST ALSO add new version upgrade logic in
+    // applySettingsMigration()!  Otherwise, settings upgrades will fail.
     const uint VERSION_MINOR_CURRENT = 6;
     // Stored minor version
     uint versionMinor = s.versionMinor();
     const uint VERSION_MINOR_CURRENT = 6;
     // Stored minor version
     uint versionMinor = s.versionMinor();
@@ -273,6 +276,8 @@ bool QtUiApplication::applySettingsMigration(QtUiSettings settings, const uint n
     //
     // In most cases, the goal is to preserve the older default values for keys that haven't been
     // saved.  Exceptions will be noted below.
     //
     // In most cases, the goal is to preserve the older default values for keys that haven't been
     // saved.  Exceptions will be noted below.
+    // NOTE:  If you add new upgrade logic here, you MUST ALSO increase VERSION_MINOR_CURRENT in
+    // migrateSettings()!  Otherwise, your upgrade logic won't ever be called.
     case 6:
     {
         // New default changes: sender colors switched around to Tango-ish theme
     case 6:
     {
         // New default changes: sender colors switched around to Tango-ish theme