mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 09:25:31 +02:00
Merge pull request #7908 from Atlante45/fix/settings
fix settings getting reset
This commit is contained in:
commit
d521cd82a0
2 changed files with 39 additions and 2 deletions
|
@ -256,7 +256,7 @@ QVariantList ScriptEngines::getRunning() {
|
|||
}
|
||||
|
||||
|
||||
static const QString SETTINGS_KEY = "Settings";
|
||||
static const QString SETTINGS_KEY = "RunningScripts";
|
||||
|
||||
void ScriptEngines::loadDefaultScripts() {
|
||||
QUrl defaultScriptsLoc = defaultScriptsLocation();
|
||||
|
@ -281,6 +281,43 @@ void ScriptEngines::loadScripts() {
|
|||
|
||||
// loads all saved scripts
|
||||
Settings settings;
|
||||
|
||||
|
||||
// START of backward compatibility code
|
||||
// This following if statement is only meant to update the settings file still using the old setting key.
|
||||
// If you read that comment and it has been more than a couple months since it was merged,
|
||||
// then by all means, feel free to remove it.
|
||||
if (!settings.childGroups().contains(SETTINGS_KEY)) {
|
||||
qWarning() << "Detected old script settings config, loading from previous location";
|
||||
const QString oldKey = "Settings";
|
||||
|
||||
// Load old scripts array from settings
|
||||
int size = settings.beginReadArray(oldKey);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
settings.setArrayIndex(i);
|
||||
QString string = settings.value("script").toString();
|
||||
if (!string.isEmpty()) {
|
||||
loadScript(string);
|
||||
}
|
||||
}
|
||||
settings.endArray();
|
||||
|
||||
// Cleanup old scripts array from settings
|
||||
settings.beginWriteArray(oldKey);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
settings.setArrayIndex(i);
|
||||
settings.remove("");
|
||||
}
|
||||
settings.endArray();
|
||||
settings.beginGroup(oldKey);
|
||||
settings.remove("size");
|
||||
settings.endGroup();
|
||||
|
||||
return;
|
||||
}
|
||||
// END of backward compatibility code
|
||||
|
||||
|
||||
int size = settings.beginReadArray(SETTINGS_KEY);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
settings.setArrayIndex(i);
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace Setting {
|
|||
}
|
||||
|
||||
void Interface::deinit() {
|
||||
if (privateInstance) {
|
||||
if (_isInitialized && privateInstance) {
|
||||
// Save value to disk
|
||||
save();
|
||||
|
||||
|
|
Loading…
Reference in a new issue