gnucash maint: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Fri Oct 1 08:49:30 EDT 2021


Updated	 via  https://github.com/Gnucash/gnucash/commit/9a465fc3 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/64576f7d (commit)
	from  https://github.com/Gnucash/gnucash/commit/71722c46 (commit)



commit 9a465fc359d96ac267aa129cf96126def59ff45e
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Sep 30 21:57:48 2021 +0200

    GSettings - add 'deprecate' and 'obsolete' conversions for user preferences
    
    'deprecate' is technically a noop. It serves to remind maintainers
    the 'deprecated' preference is to be obsoleted in the next major
    release.
    'obsolete' goes one step further in that it will cause gnucash to reset
    the preference, effectively clearing the value stored in the preferences
    backend. This is the final phase of a preference. Following this it
    will be completely removed from the GSettings schema in the next
    major release.
    
    Notes
    * 'deprecate' and 'migrate' are related. Both are a reminder the
    preference is to be obsoleted in the next major release. 'deprecate'
    does only that though while 'migrate' will also trigger a copy of
    the old value to a new location in the databse.
    
    * This commit readds a couple of preferences that had been removed
    in the past to be able to properly obsolete them (and to test
    the obsoleting code)

diff --git a/gnucash/gschemas/org.gnucash.GnuCash.deprecated.gschema.xml.in b/gnucash/gschemas/org.gnucash.GnuCash.deprecated.gschema.xml.in
index 7e626fd75..19bbcb794 100644
--- a/gnucash/gschemas/org.gnucash.GnuCash.deprecated.gschema.xml.in
+++ b/gnucash/gschemas/org.gnucash.GnuCash.deprecated.gschema.xml.in
@@ -5,6 +5,12 @@
   </schema>
 
   <schema id="org.gnucash.general" path="/org/gnucash/general/">
+    <key name="migrate-prefs-done" type="b">
+      <default>false</default>
+      <summary>-Obsolete-</summary>
+      <description>This setting is obsolete and will be removed in the next major @PROJECT_NAME@ release series.</description>
+    </key>
+
     <key name="prefs-version" type="i">
       <default>0</default>
       <summary>The version of these settings</summary>
@@ -419,6 +425,26 @@ For example setting this to 2.0 will display reports at twice their typical size
     <child name="options" schema="org.gnucash.dialogs.options"/>
   </schema>
 
+  <schema id="org.gnucash.dialogs.business-assoc" path="/org/gnucash/dialogs/business-assoc/">
+    <key type="(iiii)" name="last-geometry">
+      <default>(-1,-1,-1,-1)</default>
+      <summary>Last window position and size</summary>
+      <description>This setting describes the size and position of the window when it was last closed.
+        The numbers are the X and Y coordinates of the top left corner of the window
+        followed by the width and height of the window.</description>
+    </key>
+  </schema>
+
+  <schema id="org.gnucash.dialogs.trans-assoc" path="/org/gnucash/dialogs/trans-assoc/">
+    <key type="(iiii)" name="last-geometry">
+      <default>(-1,-1,-1,-1)</default>
+      <summary>Last window position and size</summary>
+      <description>This setting describes the size and position of the window when it was last closed.
+        The numbers are the X and Y coordinates of the top left corner of the window
+        followed by the width and height of the window.</description>
+    </key>
+  </schema>
+
   <schema id="org.gnucash.dialogs.account" path="/org/gnucash/dialogs/account/">
     <key name="last-geometry" type="(iiii)">
       <default>(-1,-1,-1,-1)</default>
diff --git a/gnucash/gschemas/org.gnucash.GnuCash.gschema.xml.in b/gnucash/gschemas/org.gnucash.GnuCash.gschema.xml.in
index 385ece719..c772b7c78 100644
--- a/gnucash/gschemas/org.gnucash.GnuCash.gschema.xml.in
+++ b/gnucash/gschemas/org.gnucash.GnuCash.gschema.xml.in
@@ -230,6 +230,7 @@
       <summary>Set book option on new files to use split "action" field for "Num" field on registers/reports</summary>
       <description>If selected, the default book option for new files is set so that the 'Num' cell on registers shows/updates the split 'action' field and the transaction 'num' field is shown on the second line in double line mode (and is not visible in single line mode). Otherwise, the default book option for new files is set so that the 'Num' cell on registers shows/updates the transaction 'num' field.</description>
     </key>
+
     <child name="register" schema="org.gnucash.GnuCash.general.register"/>
     <child name="report" schema="org.gnucash.GnuCash.general.report"/>
   </schema>
diff --git a/gnucash/gschemas/pref_transformations.xml b/gnucash/gschemas/pref_transformations.xml
index cd1dcbbe8..66f4a0191 100644
--- a/gnucash/gschemas/pref_transformations.xml
+++ b/gnucash/gschemas/pref_transformations.xml
@@ -29,12 +29,42 @@
 
     Within a release node the following rules are currently supported:
 
+    <deprecate ... /> : does nothing other than informing GnuCash devs this
+                        preference will eventually be removed with no
+                        replacement. The preference should not be used anymore
+                        in GnuCash code directly.
+                        It takes two arguments (old-path and old-key) that
+                        together define the preference
+    <migrate   ... /> : informs GnuCash a preference has moved or has been
+                        renamed. The old preference should be treated  as
+                        deprecated and should not be used anymore in GnuCash
+                        code directly.
+                        It takes four arguments (old-path, old-key and
+                        new-path, new-key). The first two define the deprecated
+                        preference the last two the replacement preference.
+    <obsolete  ... /> : informs GnuCash this preference is ready to be removed
+                        in the next major release and will be unset in this
+                        major release series. This intermediary step is to
+                        clean up the settings database over time.
+                        It takes two arguments (old-path and old-key) that
+                        together define the preference
+    Example
+    =======
+
+    <release version="4007">
+
+    <deprecate old-path="org.gnucash.GnuCash.general"
+               old-key="prefname" />
+
     <migrate old-path="org.gnucash.general"
              old-key="prefs-version"
              new-path="org.gnucash.GnuCash.general"
              new-key="prefs-version" />
 
-    This will migrate the preference at old-path:old-key to new-path:new-key.
+    <obsolete old-path="org.gnucash.general"
+              old-key="migrate-prefs-done" />
+
+    </release>
 
 
     Note
@@ -1342,3 +1372,16 @@
          new-key="end-period"/>
 
 </release>
+
+<release version="4009">
+
+<obsolete old-path="org.gnucash.dialogs.business-assoc"
+          old-key="last-geometry"/>
+
+<obsolete old-path="org.gnucash.dialogs.trans-assoc"
+          old-key="last-geometry"/>
+
+<obsolete old-path="org.gnucash.general"
+          old-key="migrate-prefs-done"/>
+
+</release>
diff --git a/libgnucash/app-utils/gnc-gsettings.cpp b/libgnucash/app-utils/gnc-gsettings.cpp
index 35fdf5646..17b25114b 100644
--- a/libgnucash/app-utils/gnc-gsettings.cpp
+++ b/libgnucash/app-utils/gnc-gsettings.cpp
@@ -655,15 +655,51 @@ gnc_gsettings_get_user_value (const gchar *schema,
     }
 }
 
+using opt_str_vec = boost::optional<std::string>;
+
+static void
+deprecate_one_key (const opt_str_vec &oldpath, const opt_str_vec &oldkey)
+{
+    if (!oldpath || !oldkey )
+    {
+        DEBUG ("Skipping <deprecate> node - missing attribute (old-path or old-key)");
+        return;
+    }
+
+    PINFO ("'%s:%s' has been marked deprecated", oldpath->c_str(), oldkey->c_str());
+    /* This does nothing really, but is a reminder for future maintainers
+     * to mark this pref as obsolete in the next major release. */
+}
+
 static void
-migrate_one_key (const std::string &oldpath, const std::string &oldkey,
-                 const std::string &newpath, const std::string &newkey)
+migrate_one_key (const opt_str_vec &oldpath, const opt_str_vec &oldkey,
+                 const opt_str_vec &newpath, const opt_str_vec &newkey)
 {
-    PINFO ("Migrating '%s:%s' to '%s:%s'", oldpath.c_str(), oldkey.c_str(),
-           newpath.c_str(), newkey.c_str());
-    auto user_value = gnc_gsettings_get_user_value (oldpath.data(), oldkey.data());
+    if (!oldpath || !oldkey || !newpath || !newkey)
+    {
+        DEBUG ("Skipping <migrate> node - missing attribute (old-path, old-key, new-path or new-key)");
+        return;
+    }
+
+    PINFO ("Migrating '%s:%s' to '%s:%s'", oldpath->c_str(), oldkey->c_str(),
+           newpath->c_str(), newkey->c_str());
+
+    auto user_value = gnc_gsettings_get_user_value (oldpath->c_str(), oldkey->c_str());
     if (user_value)
-        gnc_gsettings_set_value (newpath.data(), newkey.data(), user_value);
+        gnc_gsettings_set_value (newpath->c_str(), newkey->c_str(), user_value);
+}
+
+static void
+obsolete_one_key (const opt_str_vec &oldpath, const opt_str_vec &oldkey)
+{
+    if (!oldpath || !oldkey )
+    {
+        DEBUG ("Skipping <obsolete> node - missing attribute (old-path or old-key)");
+        return;
+    }
+
+    PINFO ("Resetting obsolete '%s:%s'", oldpath->c_str(), oldkey->c_str());
+    gnc_gsettings_reset (oldpath->c_str(), oldkey->c_str());
 }
 
 static void
@@ -675,19 +711,17 @@ parse_one_release_node (bpt::ptree &pt)
             {
                 if (node.first == "<xmlattr>")
                     return;
-                if (node.first == "migrate")
-                {
-                    auto oldpath = node.second.get_optional<std::string> ("<xmlattr>.old-path");
-                    auto oldkey = node.second.get_optional<std::string> ("<xmlattr>.old-key");
-                    auto newpath = node.second.get_optional<std::string> ("<xmlattr>.new-path");
-                    auto newkey = node.second.get_optional<std::string> ("<xmlattr>.new-key");
-                    if (!oldpath || !oldkey || !newpath || !newkey)
-                    {
-                        DEBUG ("Skipping migration node - missing attribute (old-path, old-key, new-path or new-key)");
-                        return;
-                    }
-                    migrate_one_key (*oldpath, *oldkey, *newpath, *newkey);
-                }
+                else if (node.first == "deprecate")
+                    deprecate_one_key (node.second.get_optional<std::string> ("<xmlattr>.old-path"),
+                                       node.second.get_optional<std::string> ("<xmlattr>.old-key"));
+                else if (node.first == "migrate")
+                    migrate_one_key (node.second.get_optional<std::string> ("<xmlattr>.old-path"),
+                                     node.second.get_optional<std::string> ("<xmlattr>.old-key"),
+                                     node.second.get_optional<std::string> ("<xmlattr>.new-path"),
+                                     node.second.get_optional<std::string> ("<xmlattr>.new-key"));
+                else if (node.first == "obsolete")
+                    obsolete_one_key (node.second.get_optional<std::string> ("<xmlattr>.old-path"),
+                                      node.second.get_optional<std::string> ("<xmlattr>.old-key"));
                 else
                 {
                     DEBUG ("Skipping unknown node <%s>", node.first.c_str());

commit 64576f7d27fdc3636a5fff621db22a64f8d3b7cf
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Sep 30 18:26:01 2021 +0200

    GSettings - widen scope from 'migration' to 'transformation'
    
    This commit mostly changes descriptions and variable names to
    use the more generic terms 'transformations' or 'conversions'.
    'migration' is only one possible transform, future commits will
    add others.
    There are no functional changes in this commit other than
    a logic inversion in parse_one_release_node. It now checks
    for nodes named 'migrate' rather than for nodes not named
    'migrate' (the code is adapted accordingly to match this
    logic change).

diff --git a/gnucash/CMakeLists.txt b/gnucash/CMakeLists.txt
index 01d3c27ff..8e6e339d1 100644
--- a/gnucash/CMakeLists.txt
+++ b/gnucash/CMakeLists.txt
@@ -4,7 +4,7 @@
 set(SCHEMADIR_BUILD ${DATADIR_BUILD}/glib-2.0/schemas)
 file(MAKE_DIRECTORY ${SCHEMADIR_BUILD})
 unset(gschema_depends CACHE)
-unset(gschema_migration_files CACHE)
+unset(gschema_preftrans_files CACHE)
 # The subdirectories
 add_subdirectory (gnome)
 add_subdirectory (gnome-utils)
diff --git a/gnucash/gschemas/CMakeLists.txt b/gnucash/gschemas/CMakeLists.txt
index 8b81a0161..30609736b 100644
--- a/gnucash/gschemas/CMakeLists.txt
+++ b/gnucash/gschemas/CMakeLists.txt
@@ -22,20 +22,21 @@ set(gschema_SOURCES
 
 add_gschema_targets("${gschema_SOURCES}")
 
-set(local_migration_files ${gschema_migration_files})
-list(APPEND local_migration_files ${CMAKE_CURRENT_SOURCE_DIR}/migratable-prefs.xml)
-set(gschema_migration_files ${local_migration_files} CACHE INTERNAL "gschema migration files")
+set(local_preftrans_files ${gschema_preftrans_files})
+list(APPEND local_preftrans_files ${CMAKE_CURRENT_SOURCE_DIR}/pref_transformations.xml)
+set(gschema_preftrans_files ${local_preftrans_files} CACHE INTERNAL "files describing transformations for our gsettings based preferences")
 
-# Provide gnucash runtime with a list of migratable preferences
+# Provide gnucash runtime with a list of potential transformations to user set preferences
+# following GSettings schema changes between gnucash releases
 add_custom_command(
-    OUTPUT ${DATADIR_BUILD}/${PROJECT_NAME}/migratable-prefs.xml
-    COMMAND cat ${gschema_migration_files} > ${DATADIR_BUILD}/${PROJECT_NAME}/migratable-prefs.xml
-    DEPENDS ${gschema_migration_files}
+    OUTPUT ${DATADIR_BUILD}/${PROJECT_NAME}/pref_transformations.xml
+    COMMAND cat ${gschema_preftrans_files} > ${DATADIR_BUILD}/${PROJECT_NAME}/pref_transformations.xml
+    DEPENDS ${gschema_preftrans_files}
 )
 
-add_custom_target(migratable-prefs ALL DEPENDS ${DATADIR_BUILD}/${PROJECT_NAME}/migratable-prefs.xml)
+add_custom_target(pref_transformations ALL DEPENDS ${DATADIR_BUILD}/${PROJECT_NAME}/pref_transformations.xml)
 
-install(FILES ${DATADIR_BUILD}/${PROJECT_NAME}/migratable-prefs.xml
+install(FILES ${DATADIR_BUILD}/${PROJECT_NAME}/pref_transformations.xml
         DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
 
 # Handle gschemas.compiled
@@ -65,7 +66,7 @@ if (COMPILE_GSCHEMAS)
                               ${GLIB_COMPILE_SCHEMAS} --strict \$ENV\{DESTDIR\}${CMAKE_INSTALL_FULL_DATADIR}/glib-2.0/schemas\")")
 endif()
 
-set(gschemas_DIST_local migratable-prefs.xml)
+set(gschemas_DIST_local pref_transformations.xml)
 foreach(file ${gschema_SOURCES})
     list(APPEND gschemas_DIST_local ${file}.in)
 endforeach()
diff --git a/gnucash/gschemas/migratable-prefs.xml b/gnucash/gschemas/pref_transformations.xml
similarity index 96%
rename from gnucash/gschemas/migratable-prefs.xml
rename to gnucash/gschemas/pref_transformations.xml
index 02b86cb8d..cd1dcbbe8 100644
--- a/gnucash/gschemas/migratable-prefs.xml
+++ b/gnucash/gschemas/pref_transformations.xml
@@ -1,3 +1,48 @@
+<!-- GSettings preference transformation rules
+
+    This xml file describes rules to transform the user's GSettings based
+    preferences following schema changes between GnuCash versions. These
+    rules are evaluated and (optionally) executed at runtime in order to
+    dynamically make changes to the user's preferences to adapt them to the
+    current version of GnuCash.
+
+    An example of such a transformation is changing the name of a preference.
+    While the user may have set a value for the old name, without any
+    additional work the new name would only be set to the default. As a result
+    the user would experience a reset of the preference.
+    By adding a migration rule here, GnuCash will copy the value from the old
+    name to the new name at startup and hence for the user the name change
+    becomes transparent.
+
+    All rules are grouped within 'release' nodes. Such nodes describe the
+    GnuCash version in which the related schema changes first happened.
+    GnuCash will use this information to check at runtime whether the enclosed
+    rules should still be executed.
+    The format of a release node is as follows:
+
+    <release version="encoded_version">
+       ...
+    </releaase>
+
+    encoded_version = gnucash_major  * 1000 + gnucash_minor
+    For example for gnucash 4.7 encoded_version becomes 4 * 1000 + 7 = 4007
+
+    Within a release node the following rules are currently supported:
+
+    <migrate old-path="org.gnucash.general"
+             old-key="prefs-version"
+             new-path="org.gnucash.GnuCash.general"
+             new-key="prefs-version" />
+
+    This will migrate the preference at old-path:old-key to new-path:new-key.
+
+
+    Note
+    ====
+    Do not remove this file from the GnuCash sources even if there are
+    currently no active rules. Instead keep this introductory comment in
+    place and remove all other content.
+-->
 
 <release version="4007">
 
diff --git a/gnucash/import-export/aqb/gschemas/CMakeLists.txt b/gnucash/import-export/aqb/gschemas/CMakeLists.txt
index db4016a3b..315cd284d 100644
--- a/gnucash/import-export/aqb/gschemas/CMakeLists.txt
+++ b/gnucash/import-export/aqb/gschemas/CMakeLists.txt
@@ -4,13 +4,13 @@ if (WITH_AQBANKING)
 
   add_gschema_targets("${aqb_GSCHEMA}")
 
-  set(local_migration_files ${gschema_migration_files})
-  list(APPEND local_migration_files ${CMAKE_CURRENT_SOURCE_DIR}/migratable-prefs.xml)
-  set(gschema_migration_files ${local_migration_files} CACHE INTERNAL "gschema migration files")
+  set(local_preftrans_files ${gschema_preftrans_files})
+  list(APPEND local_preftrans_files ${CMAKE_CURRENT_SOURCE_DIR}/pref_transformations.xml)
+  set(gschema_preftrans_files ${local_preftrans_files} CACHE INTERNAL "files describing transformations for our gsettings based preferences")
 endif()
 
 set_dist_list(aqbanking_gschema_DIST
   CMakeLists.txt
-  migratable-prefs.xml
+  pref_transformations.xml
   org.gnucash.GnuCash.dialogs.import.hbci.gschema.xml.in
   org.gnucash.GnuCash.dialogs.flicker.gschema.xml.in)
diff --git a/gnucash/import-export/aqb/gschemas/migratable-prefs.xml b/gnucash/import-export/aqb/gschemas/pref_transformations.xml
similarity index 100%
rename from gnucash/import-export/aqb/gschemas/migratable-prefs.xml
rename to gnucash/import-export/aqb/gschemas/pref_transformations.xml
diff --git a/gnucash/import-export/ofx/gschemas/CMakeLists.txt b/gnucash/import-export/ofx/gschemas/CMakeLists.txt
index 30626519c..6dfa158ea 100644
--- a/gnucash/import-export/ofx/gschemas/CMakeLists.txt
+++ b/gnucash/import-export/ofx/gschemas/CMakeLists.txt
@@ -4,12 +4,12 @@ if (WITH_OFX)
 
   add_gschema_targets("${ofx_GSCHEMA}")
 
-  set(local_migration_files ${gschema_migration_files})
-  list(APPEND local_migration_files ${CMAKE_CURRENT_SOURCE_DIR}/migratable-prefs.xml)
-  set(gschema_migration_files ${local_migration_files} CACHE INTERNAL "gschema migration files")
+  set(local_preftrans_files ${gschema_preftrans_files})
+  list(APPEND local_preftrans_files ${CMAKE_CURRENT_SOURCE_DIR}/pref_transformations.xml)
+  set(gschema_preftrans_files ${local_preftrans_files} CACHE INTERNAL "files describing transformations for our gsettings based preferences")
 endif()
 
 set_dist_list(ofx_gschema_DIST
   CMakeLists.txt
-  migratable-prefs.xml
+  pref_transformations.xml
   org.gnucash.GnuCash.dialogs.import.ofx.gschema.xml.in)
diff --git a/gnucash/import-export/ofx/gschemas/migratable-prefs.xml b/gnucash/import-export/ofx/gschemas/pref_transformations.xml
similarity index 100%
rename from gnucash/import-export/ofx/gschemas/migratable-prefs.xml
rename to gnucash/import-export/ofx/gschemas/pref_transformations.xml
diff --git a/libgnucash/app-utils/gnc-gsettings.cpp b/libgnucash/app-utils/gnc-gsettings.cpp
index e7b0d5fb0..35fdf5646 100644
--- a/libgnucash/app-utils/gnc-gsettings.cpp
+++ b/libgnucash/app-utils/gnc-gsettings.cpp
@@ -667,7 +667,7 @@ migrate_one_key (const std::string &oldpath, const std::string &oldkey,
 }
 
 static void
-migrate_one_node (bpt::ptree &pt)
+parse_one_release_node (bpt::ptree &pt)
 {
     /* loop over top-level property tree */
     std::for_each (pt.begin(), pt.end(),
@@ -675,53 +675,55 @@ migrate_one_node (bpt::ptree &pt)
             {
                 if (node.first == "<xmlattr>")
                     return;
-                if (node.first != "migrate")
+                if (node.first == "migrate")
                 {
-                    DEBUG ("Skipping non-<migrate> node <%s>", node.first.c_str());
-                    return;
+                    auto oldpath = node.second.get_optional<std::string> ("<xmlattr>.old-path");
+                    auto oldkey = node.second.get_optional<std::string> ("<xmlattr>.old-key");
+                    auto newpath = node.second.get_optional<std::string> ("<xmlattr>.new-path");
+                    auto newkey = node.second.get_optional<std::string> ("<xmlattr>.new-key");
+                    if (!oldpath || !oldkey || !newpath || !newkey)
+                    {
+                        DEBUG ("Skipping migration node - missing attribute (old-path, old-key, new-path or new-key)");
+                        return;
+                    }
+                    migrate_one_key (*oldpath, *oldkey, *newpath, *newkey);
                 }
-
-                auto oldpath = node.second.get_optional<std::string> ("<xmlattr>.old-path");
-                auto oldkey = node.second.get_optional<std::string> ("<xmlattr>.old-key");
-                auto newpath = node.second.get_optional<std::string> ("<xmlattr>.new-path");
-                auto newkey = node.second.get_optional<std::string> ("<xmlattr>.new-key");
-                if (!oldpath || !oldkey || !newpath || !newkey)
+                else
                 {
-                    DEBUG ("Skipping migration node - missing attribute (old-path, old-key, new-path or new-key)");
+                    DEBUG ("Skipping unknown node <%s>", node.first.c_str());
                     return;
                 }
-                migrate_one_key (*oldpath, *oldkey, *newpath, *newkey);
             });
 }
 
 static void
-migrate_settings (int old_maj_min)
+transform_settings (int old_maj_min)
 {
     bpt::ptree pt;
 
     auto pkg_data_dir = gnc_path_get_pkgdatadir();
-    auto migrate_file = std::string (pkg_data_dir) + "/migratable-prefs.xml";
+    auto transform_file = std::string (pkg_data_dir) + "/pref_transformations.xml";
     g_free (pkg_data_dir);
 
-    std::ifstream migrate_stream {migrate_file};
-    if (!migrate_stream.is_open())
+    std::ifstream transform_stream {transform_file};
+    if (!transform_stream.is_open())
     {
-        PWARN("Failed to load settings migration file '%s'", migrate_file.c_str());
+        PWARN("Failed to load preferences transformation file '%s'", transform_file.c_str());
         return;
     }
 
     try
     {
-        bpt::read_xml (migrate_stream, pt);
+        bpt::read_xml (transform_stream, pt);
     }
     catch (bpt::xml_parser_error &e) {
-        PWARN ("Failed to parse GnuCash settings migration file.\n");
+        PWARN ("Failed to parse GnuCash preferences transformation file.\n");
         PWARN ("Error message:\n");
         PWARN ("%s\n", e.what());
         return;
     }
     catch (...) {
-        PWARN ("Unknown error while parsing GnuCash settings migration file.\n");
+        PWARN ("Unknown error while parsing GnuCash preferences transformation file.\n");
         return;
     }
 
@@ -747,27 +749,36 @@ migrate_settings (int old_maj_min)
                 }
                 DEBUG ("Retrieved version value '%i'", *version);
 
-                migrate_one_node (node.second);
+                parse_one_release_node (node.second);
             });
 }
 
 void gnc_gsettings_version_upgrade (void)
 {
-    /* Use versioning to ensure this routine will only sync once for each
-     * superseded setting
-     * At first run of GnuCash 4.7 or more recent *all* settings will be migrated
-     * from prefix org.gnucash to org.gnucash.GnuCash, including our GNC_PREF_VERSION setting.
-     * As the logic to determine whether or not to upgrade depends on it we have to do
-     * some extra tests to figure when exactly to start doing migrations.
-     * - if GNC_PREF_VERSION is not set under old nor new prefix, that means
-     *   gnucash has never run before on this system = no migration necessary
-     * - if GNC_PREF_VERSION is set under old prefix, but not new prefix
-     *   => full migration from old to new prefix should still be run
+    /* This routine will conditionally execute conversion rules from
+     * prefs_transformations.xml to adapt the user's existing preferences to
+     * the current preferences schema. The rules in this file are versioned and
+     * only rules still relevant to the user's existing preferences and for
+     * this version of GnuCash will be executed.
+     *
+     * Starting with GnuCash 4.7 the code expects all preferences to be stored
+     * under prefix org.gnucash instead of org.gnucash.GnuCash, including our
+     * GNC_PREF_VERSION setting.
+     * As the logic to determine whether or not settings conversions are needed
+     * depends on this preference, we have to test for its value in two
+     * locations:
+     * - if GNC_PREF_VERSION is not set under old nor new prefix
+     *   => GnuCash has never run before so no conversion run necessary
+     * - if GNC_PREF_VERSION is set under old prefix and not new prefix
+     *   => user's preferences weren't moved yet from old to new prefix. Use old
+     *      prefix GNC_PREF_VERSION to determine which conversions may be needed
      * - if GNC_PREF_VERSION is set under both prefixes
-     *   => ignore old prefix and use new prefix result to determine which
-     *   migrations would still be needed.
+     *   => ignore old prefix and use new prefix GNC_PREF_VERSION to determine
+     *      which conversions may be needed.
+     * Sometime in the future (GnuCash 6.0) the old prefix will be fully removed
+     * and the test will be simplified to only check in the new prefix.
      */
-    ENTER("Start of settings migration routine.");
+    ENTER("Start of settings transform routine.");
 
     auto ogG_maj_min = gnc_gsettings_get_user_value (GNC_PREFS_GROUP_GENERAL, GNC_PREF_VERSION);
     auto og_maj_min = gnc_gsettings_get_user_value (GSET_SCHEMA_OLD_PREFIX "." GNC_PREFS_GROUP_GENERAL, GNC_PREF_VERSION);
@@ -790,7 +801,7 @@ void gnc_gsettings_version_upgrade (void)
 
     PINFO ("Previous setting compatibility level: %i", old_maj_min);
 
-    migrate_settings (old_maj_min);
+    transform_settings (old_maj_min);
 
     /* Only write current version if it's more recent than what was set */
     auto cur_maj_min = PROJECT_VERSION_MAJOR * 1000 + PROJECT_VERSION_MINOR;



Summary of changes:
 gnucash/CMakeLists.txt                             |   2 +-
 gnucash/gschemas/CMakeLists.txt                    |  21 ++--
 .../org.gnucash.GnuCash.deprecated.gschema.xml.in  |  26 ++++
 .../gschemas/org.gnucash.GnuCash.gschema.xml.in    |   1 +
 ...gratable-prefs.xml => pref_transformations.xml} |  88 ++++++++++++++
 gnucash/import-export/aqb/gschemas/CMakeLists.txt  |   8 +-
 ...gratable-prefs.xml => pref_transformations.xml} |   0
 gnucash/import-export/ofx/gschemas/CMakeLists.txt  |   8 +-
 ...gratable-prefs.xml => pref_transformations.xml} |   0
 libgnucash/app-utils/gnc-gsettings.cpp             | 131 ++++++++++++++-------
 10 files changed, 223 insertions(+), 62 deletions(-)
 rename gnucash/gschemas/{migratable-prefs.xml => pref_transformations.xml} (92%)
 rename gnucash/import-export/aqb/gschemas/{migratable-prefs.xml => pref_transformations.xml} (100%)
 rename gnucash/import-export/ofx/gschemas/{migratable-prefs.xml => pref_transformations.xml} (100%)



More information about the gnucash-changes mailing list