Make explicit that MatrixClient & Cache are unique pointers

remotes/origin/HEAD
Konstantinos Sideris 7 years ago
parent 701aa93b0a
commit 05585ff8cf
  1. 2
      include/Cache.h
  2. 2
      include/MatrixClient.h
  3. 8
      src/Cache.cc
  4. 2
      src/ChatPage.cc
  5. 2
      src/MainWindow.cc
  6. 8
      src/MatrixClient.cc

@ -438,7 +438,7 @@ private:
namespace cache {
void
init(const QString &userId, QObject *parent);
init(const QString &user_id);
Cache *
client();

@ -215,7 +215,7 @@ private:
namespace http {
//! Initialize the http module
void
init(QObject *parent);
init();
//! Retrieve the client instance.
MatrixClient *

@ -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();
}
}

@ -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();

@ -55,7 +55,7 @@ MainWindow::MainWindow(QWidget *parent)
setObjectName("MainWindow");
// Initialize the http client.
http::init(this);
http::init();
restoreWindowSize();

@ -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();
}
}

Loading…
Cancel
Save