mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 16:23:07 -07: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:
parent
8b330e3ac0
commit
5de75eff05
9 changed files with 39 additions and 34 deletions
|
@ -149,7 +149,7 @@ Application::Application(const QString &id, int &argc, char **argv)
|
|||
const QString profileDir = portableModeEnabled
|
||||
? QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(DEFAULT_PORTABLE_MODE_PROFILE_DIR)
|
||||
: m_commandLineArgs.profileDir;
|
||||
Profile::initialize(profileDir, m_commandLineArgs.configurationName,
|
||||
Profile::initInstance(profileDir, m_commandLineArgs.configurationName,
|
||||
(m_commandLineArgs.relativeFastresumePaths || portableModeEnabled));
|
||||
|
||||
Logger::initInstance();
|
||||
|
@ -177,7 +177,7 @@ Application::Application(const QString &id, int &argc, char **argv)
|
|||
Logger::instance()->addMessage(tr("Redundant command line flag detected: \"%1\". Portable mode implies relative fastresume.").arg("--relative-fastresume"), Log::WARNING); // to avoid translating the `--relative-fastresume` string
|
||||
}
|
||||
else {
|
||||
Logger::instance()->addMessage(tr("Using config directory: %1").arg(Profile::instance().location(SpecialFolder::Config)));
|
||||
Logger::instance()->addMessage(tr("Using config directory: %1").arg(Profile::instance()->location(SpecialFolder::Config)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -764,6 +764,8 @@ void Application::cleanup()
|
|||
}
|
||||
#endif // DISABLE_GUI
|
||||
|
||||
Profile::freeInstance();
|
||||
|
||||
if (m_shutdownAct != ShutdownDialogAction::Exit) {
|
||||
qDebug() << "Sending computer shutdown/suspend/hibernate signal...";
|
||||
Utils::Misc::shutdownComputer(m_shutdownAct);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue