summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-05-11 13:41:46 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-05-11 13:41:46 +0300
commit05585ff8cf9ef090c7158af47d99df835a22686d (patch)
tree6599b9b5674bb780e174667a9b9dee079f5a4b30 /src
parentAdd scrollbar in the settings menu (diff)
downloadnheko-05585ff8cf9ef090c7158af47d99df835a22686d.tar.xz
Make explicit that MatrixClient & Cache are unique pointers
Diffstat (limited to 'src')
-rw-r--r--src/Cache.cc8
-rw-r--r--src/ChatPage.cc2
-rw-r--r--src/MainWindow.cc2
-rw-r--r--src/MatrixClient.cc8
4 files changed, 10 insertions, 10 deletions
diff --git a/src/Cache.cc b/src/Cache.cc

index d80834aa..23d37f58 100644 --- a/src/Cache.cc +++ b/src/Cache.cc
@@ -54,21 +54,21 @@ using CachedReceipts = std::multimap<uint64_t, std::string, std::greater<uint64_ using Receipts = std::map<std::string, std::map<std::string, uint64_t>>; namespace { -Cache *instance_ = nullptr; +std::unique_ptr<Cache> instance_ = nullptr; } namespace cache { void -init(const QString &user_id, QObject *parent) +init(const QString &user_id) { if (!instance_) - instance_ = new Cache(user_id, parent); + instance_ = std::make_unique<Cache>(user_id); } Cache * client() { - return instance_; + return instance_.get(); } } diff --git a/src/ChatPage.cc b/src/ChatPage.cc
index 7f08eda6..6040dc66 100644 --- a/src/ChatPage.cc +++ b/src/ChatPage.cc
@@ -497,7 +497,7 @@ ChatPage::bootstrap(QString userid, QString homeserver, QString token) http::client()->getOwnProfile(); http::client()->getOwnCommunities(); - cache::init(userid, this); + cache::init(userid); try { cache::client()->setup(); diff --git a/src/MainWindow.cc b/src/MainWindow.cc
index e256e6c9..c46cbff1 100644 --- a/src/MainWindow.cc +++ b/src/MainWindow.cc
@@ -55,7 +55,7 @@ MainWindow::MainWindow(QWidget *parent) setObjectName("MainWindow"); // Initialize the http client. - http::init(this); + http::init(); restoreWindowSize(); diff --git a/src/MatrixClient.cc b/src/MatrixClient.cc
index c6ca74ad..6336a5cf 100644 --- a/src/MatrixClient.cc +++ b/src/MatrixClient.cc
@@ -34,22 +34,22 @@ #include "MatrixClient.h" namespace { -MatrixClient *instance_ = nullptr; +std::unique_ptr<MatrixClient> instance_ = nullptr; } namespace http { void -init(QObject *parent) +init() { if (!instance_) - instance_ = new MatrixClient(parent); + instance_ = std::make_unique<MatrixClient>(); } MatrixClient * client() { - return instance_; + return instance_.get(); } }