mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-25 03:12:56 +00:00
open file exclusively for read/write in QSettingsPrivate::write()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
d688393bcb
commit
edf8ef3b4d
1 changed files with 7 additions and 5 deletions
|
@ -286,21 +286,23 @@ void QSettingsPrivate::write()
|
||||||
}
|
}
|
||||||
|
|
||||||
QMutexLocker locker(qSettingsMutex());
|
QMutexLocker locker(qSettingsMutex());
|
||||||
QFile file(filename);
|
QFile writefile(filename);
|
||||||
if (Q_UNLIKELY(!file.open(QFile::ReadWrite))) {
|
if (Q_UNLIKELY(!writefile.open(QFile::WriteOnly))) {
|
||||||
status = QSettings::AccessError;
|
status = QSettings::AccessError;
|
||||||
qWarning("QSettingsPrivate::write: failed to open %s", filename.toLocal8Bit().constData());
|
qWarning("QSettingsPrivate::write: failed to open %s", filename.toLocal8Bit().constData());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettings::SettingsMap mergemap;
|
QSettings::SettingsMap mergemap;
|
||||||
readFunc(file, mergemap);
|
QFile readfile(filename);
|
||||||
file.seek(0);
|
if (readfile.open(QFile::ReadOnly)) {
|
||||||
|
readFunc(readfile, mergemap);
|
||||||
|
}
|
||||||
foreach(const QString &key, map.keys()) {
|
foreach(const QString &key, map.keys()) {
|
||||||
mergemap.insert(key, map.value(key));
|
mergemap.insert(key, map.value(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Q_UNLIKELY(!writeFunc(file, mergemap))) {
|
if (Q_UNLIKELY(!writeFunc(writefile, mergemap))) {
|
||||||
status = QSettings::FormatError;
|
status = QSettings::FormatError;
|
||||||
qWarning("QSettingsPrivate::write: could not write %s", filename.toLocal8Bit().constData());
|
qWarning("QSettingsPrivate::write: could not write %s", filename.toLocal8Bit().constData());
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue