mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix working with settings before Domain::started.
This commit is contained in:
parent
4a8d297df3
commit
28570b45e3
1 changed files with 13 additions and 7 deletions
|
@ -79,10 +79,11 @@ FileKey _backgroundKeyDay = 0;
|
||||||
FileKey _backgroundKeyNight = 0;
|
FileKey _backgroundKeyNight = 0;
|
||||||
bool _useGlobalBackgroundKeys = false;
|
bool _useGlobalBackgroundKeys = false;
|
||||||
bool _backgroundCanWrite = true;
|
bool _backgroundCanWrite = true;
|
||||||
bool _backgroundMigrated = false;
|
|
||||||
|
|
||||||
int32 _oldSettingsVersion = 0;
|
int32 _oldSettingsVersion = 0;
|
||||||
bool _settingsRewritten;
|
bool _settingsRewritten = false;
|
||||||
|
bool _settingsRewriteNeeded = false;
|
||||||
|
bool _settingsWriteAllowed = false;
|
||||||
|
|
||||||
enum class WriteMapWhen {
|
enum class WriteMapWhen {
|
||||||
Now,
|
Now,
|
||||||
|
@ -416,6 +417,10 @@ void start() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeSettings() {
|
void writeSettings() {
|
||||||
|
if (!_settingsWriteAllowed) {
|
||||||
|
_settingsRewriteNeeded = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (_basePath.isEmpty()) {
|
if (_basePath.isEmpty()) {
|
||||||
LOG(("App Error: _basePath is empty in writeSettings()"));
|
LOG(("App Error: _basePath is empty in writeSettings()"));
|
||||||
return;
|
return;
|
||||||
|
@ -520,12 +525,13 @@ void writeSettings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void rewriteSettingsIfNeeded() {
|
void rewriteSettingsIfNeeded() {
|
||||||
if (_settingsRewritten
|
if (_settingsWriteAllowed) {
|
||||||
|| (_oldSettingsVersion == AppVersion && !_backgroundMigrated)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_settingsRewritten = true;
|
_settingsWriteAllowed = true;
|
||||||
writeSettings();
|
if (_oldSettingsVersion < AppVersion || _settingsRewriteNeeded) {
|
||||||
|
writeSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &AutoupdatePrefix(const QString &replaceWith = {}) {
|
const QString &AutoupdatePrefix(const QString &replaceWith = {}) {
|
||||||
|
@ -786,7 +792,7 @@ void moveLegacyBackground(
|
||||||
};
|
};
|
||||||
move(legacyBackgroundKeyDay, _backgroundKeyDay);
|
move(legacyBackgroundKeyDay, _backgroundKeyDay);
|
||||||
move(legacyBackgroundKeyNight, _backgroundKeyNight);
|
move(legacyBackgroundKeyNight, _backgroundKeyNight);
|
||||||
_backgroundMigrated = true;
|
_settingsRewriteNeeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue