mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-21 16:07:23 -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:
@@ -36,8 +36,6 @@
|
||||
|
||||
class QString;
|
||||
|
||||
class Application;
|
||||
|
||||
namespace Private
|
||||
{
|
||||
class Profile;
|
||||
@@ -57,6 +55,11 @@ enum class SpecialFolder
|
||||
class Profile
|
||||
{
|
||||
public:
|
||||
static void initInstance(const QString &rootProfilePath, const QString &configurationName,
|
||||
bool convertPathsToProfileRelative);
|
||||
static void freeInstance();
|
||||
static const Profile *instance();
|
||||
|
||||
QString location(SpecialFolder folder) const;
|
||||
SettingsPtr applicationSettings(const QString &name) const;
|
||||
|
||||
@@ -67,16 +70,11 @@ public:
|
||||
QString toPortablePath(const QString &absolutePath) const;
|
||||
QString fromPortablePath(const QString &portablePath) const;
|
||||
|
||||
static const Profile &instance();
|
||||
|
||||
private:
|
||||
Profile(Private::Profile *impl, Private::PathConverter *pathConverter);
|
||||
~Profile();
|
||||
~Profile() = default; // to generate correct call to ProfilePrivate::~ProfileImpl()
|
||||
|
||||
friend class ::Application;
|
||||
static void initialize(const QString &rootProfilePath, const QString &configurationName,
|
||||
bool convertPathsToProfileRelative);
|
||||
void ensureDirectoryExists(SpecialFolder folder);
|
||||
void ensureDirectoryExists(SpecialFolder folder) const;
|
||||
|
||||
const std::unique_ptr<Private::Profile> m_profileImpl;
|
||||
const std::unique_ptr<Private::PathConverter> m_pathConverterImpl;
|
||||
|
||||
Reference in New Issue
Block a user