[education/rkward] /: Remove some really old config import code. When config is too old, just discard it.
Thomas Friedrichsmeier
null at kde.org
Mon May 9 19:50:10 BST 2022
Git commit 2a37bbd7a36e1da70fda4ac10e328a71cb68763b by Thomas Friedrichsmeier.
Committed on 09/05/2022 at 18:50.
Pushed by tfry into branch 'master'.
Remove some really old config import code. When config is too old, just discard it.
M +1 -1 ChangeLog
M +14 -12 rkward/settings/rksettingsmodulegeneral.cpp
M +5 -6 rkward/settings/rksettingsmodulegeneral.h
M +2 -13 rkward/settings/rksettingsmoduler.cpp
https://invent.kde.org/education/rkward/commit/2a37bbd7a36e1da70fda4ac10e328a71cb68763b
diff --git a/ChangeLog b/ChangeLog
index b28e091f..484a177b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,7 @@
TODOs:
- More tolerant handshake on Windows? Simply a matter of allowing more time?
- - If stored config is older than 0.6.3, discard it, entirely
+- When directly upgrading from very old versions (pre 0.6.3, currently), discard existing config settings
- Plugin maps with the same id are grouped together, and the most recent version is used, automatically
- Added functionality to install add-on packages directly from git (formerly available as external plugin rk.gitInstall)
- TODO: add a plugintest
diff --git a/rkward/settings/rksettingsmodulegeneral.cpp b/rkward/settings/rksettingsmodulegeneral.cpp
index 230d8989..662babf2 100644
--- a/rkward/settings/rksettingsmodulegeneral.cpp
+++ b/rkward/settings/rksettingsmodulegeneral.cpp
@@ -38,7 +38,6 @@ RKConfigValue<bool> RKSettingsModuleGeneral::show_help_on_startup {"show help on
RKConfigValue<int> RKSettingsModuleGeneral::warn_size_object_edit {"large object warning limit", 250000};
RKConfigValue<RKSettingsModuleGeneral::RKMDIFocusPolicy, int> RKSettingsModuleGeneral::mdi_focus_policy {"focus policy", RKMDIClickFocus};
RKSettingsModuleGeneral::RKWardConfigVersion RKSettingsModuleGeneral::stored_config_version;
-bool RKSettingsModuleGeneral::config_exists;
RKConfigValue<RKSettingsModuleGeneral::InitialDirectory, int> RKSettingsModuleGeneral::initial_dir {"initial dir mode",
#ifndef Q_OS_WIN
CurrentDirectory
@@ -164,11 +163,23 @@ void RKSettingsModuleGeneral::applyChanges () {
void RKSettingsModuleGeneral::syncConfig(KConfig *config, RKConfigBase::ConfigSyncAction a) {
RK_TRACE (SETTINGS);
+ KConfigGroup cg;
+ bool config_exists = config->hasGroup("General"); // one of the very oldest groups in the config
+ cg = config->group ("Internal");
if (a == RKConfigBase::LoadConfig) {
- config_exists = config->hasGroup("General"); // one of the very oldest groups in the config
+ stored_config_version = (RKWardConfigVersion) cg.readEntry("config file version", (int) RKWardConfig_Pre0_5_7_Obsolete);
+ if (config_exists && stored_config_version < RKWardConfig_0_6_3) {
+ QStringList groups = config->groupList();
+ for (int i = 0; i < groups.size(); ++i) {
+ config->deleteGroup(groups[i]);
+ }
+ }
+ rkward_version_changed = (cg.readEntry("previous runtime version", QString()) != RKWARD_VERSION);
+ } else {
+ cg.writeEntry("config file version", (int) RKWardConfig_Latest);
+ cg.writeEntry("previous runtime version", QString(RKWARD_VERSION));
}
- KConfigGroup cg;
cg = config->group("Logfiles");
if (a == RKConfigBase::LoadConfig) {
// default not yet set, first time loading config
@@ -207,15 +218,6 @@ void RKSettingsModuleGeneral::syncConfig(KConfig *config, RKConfigBase::ConfigSy
cg = config->group ("MDI");
mdi_focus_policy.syncConfig(cg, a);
- cg = config->group ("Internal");
- if (a == RKConfigBase::LoadConfig) {
- stored_config_version = (RKWardConfigVersion) cg.readEntry("config file version", (int) RKWardConfig_Pre0_5_7);
- rkward_version_changed = (cg.readEntry("previous runtime version", QString()) != RKWARD_VERSION);
- } else {
- cg.writeEntry("config file version", (int) RKWardConfig_Latest);
- cg.writeEntry("previous runtime version", QString(RKWARD_VERSION));
- }
-
if ((a == RKConfigBase::LoadConfig) && (stored_config_version < RKWardConfig_0_7_4)) {
show_help_on_startup = true;
}
diff --git a/rkward/settings/rksettingsmodulegeneral.h b/rkward/settings/rksettingsmodulegeneral.h
index 38304109..099c1af2 100644
--- a/rkward/settings/rksettingsmodulegeneral.h
+++ b/rkward/settings/rksettingsmodulegeneral.h
@@ -70,10 +70,12 @@ public:
* TODO: similar, but not quite identical functionality in rkworkplace.cpp checkAdjustRestoredUrl(). Might be mergeable. */
static QString checkAdjustLoadedPath (const QString &localpath);
+ /** Enum for config version, one entry added for each incompatible change. "_Obsolete" members are no longer supported for
+ * config import (config is discarded for those). They are still kept in the enum for correct numbering. */
enum RKWardConfigVersion {
- RKWardConfig_Pre0_5_7,
- RKWardConfig_0_5_7,
- RKWardConfig_0_6_1,
+ RKWardConfig_Pre0_5_7_Obsolete,
+ RKWardConfig_0_5_7_Obsolete,
+ RKWardConfig_0_6_1_Obsolete,
RKWardConfig_0_6_3,
RKWardConfig_0_6_4,
RKWardConfig_0_7_1,
@@ -86,8 +88,6 @@ public:
* @return RKWardConfig_Pre0_5_7, if no config file could be read. See anyExistingConfig()
* @note Not all versions of RKWard have a config file version of their own, not even necessarily when new entries were added. Only when not-quite-compatible changes are needed, new config versions will be added. */
static RKWardConfigVersion storedConfigVersion () { return stored_config_version; };
- /** Did a config file already exist? */
- static bool anyExistingConfig () { return config_exists; };
/** Returns true, if the runtime version of RKWard has changed since the previous session. */
static bool rkwardVersionChanged () { return rkward_version_changed; };
/** Returns true, if rkward seems to have started from a different path than on the previous run. */
@@ -115,7 +115,6 @@ private:
static QString previous_rkward_data_dir;
static RKWardConfigVersion stored_config_version;
static bool rkward_version_changed;
- static bool config_exists;
static bool installation_moved;
static RKConfigValue<int> num_recent_files;
diff --git a/rkward/settings/rksettingsmoduler.cpp b/rkward/settings/rksettingsmoduler.cpp
index f4d01a9a..e152d9f8 100755
--- a/rkward/settings/rksettingsmoduler.cpp
+++ b/rkward/settings/rksettingsmoduler.cpp
@@ -570,23 +570,12 @@ void RKSettingsModuleRPackages::syncConfig(KConfig *config, RKConfigBase::Config
package_repositories.syncConfig(cg, a);
if (a == RKConfigBase::LoadConfig) {
- const QString rkward_repo (RKWARD_REPO);
- if (RKSettingsModuleGeneral::storedConfigVersion () <= RKSettingsModuleGeneral::RKWardConfig_Pre0_5_7) {
- auto v = package_repositories.get();
- v.removeAll ("@CRAN@"); // COMPAT: Cran mirror was part of this list before 0.5.3
- if (v.isEmpty ()) v.append(rkward_repo);
- package_repositories = v;
- } else if (RKSettingsModuleGeneral::storedConfigVersion () < RKSettingsModuleGeneral::RKWardConfig_0_6_3) {
+ if (RKSettingsModuleGeneral::storedConfigVersion () < RKSettingsModuleGeneral::RKWardConfig_0_6_3) {
auto v = package_repositories.get();
v.removeAll("http://rkward.sf.net/R");
- v.append(rkward_repo);
+ v.append(RKWARD_REPO);
package_repositories = v;
}
-
- if (USE_SOURCE_PACKAGES && (RKSettingsModuleGeneral::storedConfigVersion () < RKSettingsModuleGeneral::RKWardConfig_0_6_1)) {
- // revert default on MacOSX, even if a previous stored setting exists
- source_packages = true;
- }
}
}
More information about the rkward-tracker
mailing list