Verified Commit 1c45a41d authored by Jonah Brüchert's avatar Jonah Brüchert 🌳
Browse files

BrowserManager: Make constructor private

It should always be created using instance()
parent 76697974
...@@ -34,7 +34,7 @@ private Q_SLOTS: ...@@ -34,7 +34,7 @@ private Q_SLOTS:
void initTestCase() void initTestCase()
{ {
m_browserManager = new BrowserManager(); m_browserManager = BrowserManager::instance();
} }
void cleanupTestCase() void cleanupTestCase()
......
...@@ -32,7 +32,6 @@ BrowserManager *BrowserManager::s_instance = nullptr; ...@@ -32,7 +32,6 @@ BrowserManager *BrowserManager::s_instance = nullptr;
BrowserManager::BrowserManager(QObject *parent) : QObject(parent), m_settings(new QSettings(this)) BrowserManager::BrowserManager(QObject *parent) : QObject(parent), m_settings(new QSettings(this))
{ {
BrowserManager::s_instance = this;
} }
BrowserManager::~BrowserManager() BrowserManager::~BrowserManager()
......
...@@ -49,7 +49,6 @@ class BrowserManager : public QObject ...@@ -49,7 +49,6 @@ class BrowserManager : public QObject
Q_PROPERTY(QString initialUrl READ initialUrl WRITE setInitialUrl NOTIFY initialUrlChanged) Q_PROPERTY(QString initialUrl READ initialUrl WRITE setInitialUrl NOTIFY initialUrlChanged)
public: public:
BrowserManager(QObject *parent = nullptr);
~BrowserManager() override; ~BrowserManager() override;
static BrowserManager *instance(); static BrowserManager *instance();
...@@ -85,6 +84,9 @@ public slots: ...@@ -85,6 +84,9 @@ public slots:
void setSearchBaseUrl(const QString &searchBaseUrl); void setSearchBaseUrl(const QString &searchBaseUrl);
private: private:
// BrowserManager should only be createdd by calling the instance() function
BrowserManager(QObject *parent = nullptr);
UrlModel *m_bookmarks = nullptr; UrlModel *m_bookmarks = nullptr;
UrlModel *m_history = nullptr; UrlModel *m_history = nullptr;
QSettings *m_settings; QSettings *m_settings;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment