Fixed settings reset in case of tiled background.

This commit is contained in:
John Preston 2016-09-15 13:26:31 +03:00
parent 3423bd69dc
commit 96202f775c
1 changed files with 13 additions and 0 deletions

View File

@ -581,6 +581,7 @@ namespace {
FileKey _backgroundKey = 0;
bool _backgroundWasRead = false;
bool _readingUserSettings = false;
FileKey _userSettingsKey = 0;
FileKey _recentHashtagsAndBotsKey = 0;
bool _recentHashtagsAndBotsWereRead = false;
@ -1548,6 +1549,12 @@ namespace {
}
void _writeUserSettings() {
if (_readingUserSettings) {
LOG(("App Error: attempt to write settings while reading them!"));
return;
}
LOG(("App Info: writing encrypted user settings..."));
if (!_userSettingsKey) {
_userSettingsKey = genKey();
_mapChanged = true;
@ -1622,22 +1629,28 @@ namespace {
void _readUserSettings() {
FileReadDescriptor userSettings;
if (!readEncryptedFile(userSettings, _userSettingsKey)) {
LOG(("App Info: could not read encrypted user settings..."));
_readOldUserSettings();
return _writeUserSettings();
}
LOG(("App Info: reading encrypted user settings..."));
_readingUserSettings = true;
while (!userSettings.stream.atEnd()) {
quint32 blockId;
userSettings.stream >> blockId;
if (!_checkStreamStatus(userSettings.stream)) {
_readingUserSettings = false;
return _writeUserSettings();
}
if (!_readSetting(blockId, userSettings.stream, userSettings.version)) {
_readingUserSettings = false;
return _writeUserSettings();
}
}
_readingUserSettings = false;
LOG(("App Info: encrypted user settings read."));
}
void _writeMtpData() {