|
|
@ -186,18 +186,18 @@ SettingsStorage *SettingsStorage::instance() |
|
|
|
|
|
|
|
|
|
|
|
bool SettingsStorage::save() |
|
|
|
bool SettingsStorage::save() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!m_dirty) return false; // Obtaining the lock is expensive, let's check early
|
|
|
|
if (!m_dirty) return true; // Obtaining the lock is expensive, let's check early
|
|
|
|
const QWriteLocker locker(&m_lock); |
|
|
|
const QWriteLocker locker(&m_lock); // to guard for `m_dirty`
|
|
|
|
if (!m_dirty) return false; // something might have changed while we were getting the lock
|
|
|
|
if (!m_dirty) return true; // something might have changed while we were getting the lock
|
|
|
|
|
|
|
|
|
|
|
|
const TransactionalSettings settings(QLatin1String("qBittorrent")); |
|
|
|
const TransactionalSettings settings(QLatin1String("qBittorrent")); |
|
|
|
if (settings.write(m_data)) { |
|
|
|
if (!settings.write(m_data)) { |
|
|
|
m_dirty = false; |
|
|
|
m_timer.start(); |
|
|
|
return true; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_timer.start(); |
|
|
|
m_dirty = false; |
|
|
|
return false; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QVariant SettingsStorage::loadValue(const QString &key, const QVariant &defaultValue) const |
|
|
|
QVariant SettingsStorage::loadValue(const QString &key, const QVariant &defaultValue) const |
|
|
|