mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-03 06:02:29 -06:00
Unify singleton pattern in Profile class
1. Use unified function names `initInstance()` and `freeInstance()` and make them public. 2. Add `freeInstance()` to avoid noise from memory leak detectors. 3. Let `instance()`return a pointer directly to avoid unnecessary indirections when invoking functions.
This commit is contained in:
committed by
sledgehammer999
parent
5e73afa04e
commit
534549142e
@@ -90,7 +90,7 @@ void Statistics::save() const
|
||||
if (!m_dirty || ((now - m_lastWrite) < SAVE_INTERVAL))
|
||||
return;
|
||||
|
||||
SettingsPtr s = Profile::instance().applicationSettings(QLatin1String("qBittorrent-data"));
|
||||
SettingsPtr s = Profile::instance()->applicationSettings(QLatin1String("qBittorrent-data"));
|
||||
QVariantHash v;
|
||||
v.insert("AlltimeDL", m_alltimeDL + m_sessionDL);
|
||||
v.insert("AlltimeUL", m_alltimeUL + m_sessionUL);
|
||||
@@ -101,7 +101,7 @@ void Statistics::save() const
|
||||
|
||||
void Statistics::load()
|
||||
{
|
||||
const SettingsPtr s = Profile::instance().applicationSettings(QLatin1String("qBittorrent-data"));
|
||||
const SettingsPtr s = Profile::instance()->applicationSettings(QLatin1String("qBittorrent-data"));
|
||||
const QVariantHash v = s->value("Stats/AllStats").toHash();
|
||||
|
||||
m_alltimeDL = v["AlltimeDL"].toULongLong();
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace
|
||||
torrentParams.restored = true;
|
||||
torrentParams.skipChecking = false;
|
||||
torrentParams.name = fromLTString(root.dict_find_string_value("qBt-name"));
|
||||
torrentParams.savePath = Profile::instance().fromPortablePath(
|
||||
torrentParams.savePath = Profile::instance()->fromPortablePath(
|
||||
Utils::Fs::toUniformPath(fromLTString(root.dict_find_string_value("qBt-savePath"))));
|
||||
torrentParams.disableTempPath = root.dict_find_int_value("qBt-tempPathDisabled");
|
||||
torrentParams.sequential = root.dict_find_int_value("qBt-sequential");
|
||||
|
||||
@@ -1763,9 +1763,9 @@ void TorrentHandle::handleSaveResumeDataAlert(const lt::save_resume_data_alert *
|
||||
}
|
||||
else {
|
||||
const auto savePath = resumeData.find_key("save_path")->string();
|
||||
resumeData["save_path"] = Profile::instance().toPortablePath(QString::fromStdString(savePath)).toStdString();
|
||||
resumeData["save_path"] = Profile::instance()->toPortablePath(QString::fromStdString(savePath)).toStdString();
|
||||
}
|
||||
resumeData["qBt-savePath"] = m_useAutoTMM ? "" : Profile::instance().toPortablePath(m_savePath).toStdString();
|
||||
resumeData["qBt-savePath"] = m_useAutoTMM ? "" : Profile::instance()->toPortablePath(m_savePath).toStdString();
|
||||
resumeData["qBt-ratioLimit"] = static_cast<int>(m_ratioLimit * 1000);
|
||||
resumeData["qBt-seedingTimeLimit"] = m_seedingTimeLimit;
|
||||
resumeData["qBt-category"] = m_category.toStdString();
|
||||
|
||||
Reference in New Issue
Block a user