Make explicit that MatrixClient & Cache are unique pointers
This commit is contained in:
parent
701aa93b0a
commit
05585ff8cf
@ -438,7 +438,7 @@ private:
|
|||||||
|
|
||||||
namespace cache {
|
namespace cache {
|
||||||
void
|
void
|
||||||
init(const QString &userId, QObject *parent);
|
init(const QString &user_id);
|
||||||
|
|
||||||
Cache *
|
Cache *
|
||||||
client();
|
client();
|
||||||
|
@ -215,7 +215,7 @@ private:
|
|||||||
namespace http {
|
namespace http {
|
||||||
//! Initialize the http module
|
//! Initialize the http module
|
||||||
void
|
void
|
||||||
init(QObject *parent);
|
init();
|
||||||
|
|
||||||
//! Retrieve the client instance.
|
//! Retrieve the client instance.
|
||||||
MatrixClient *
|
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>>;
|
using Receipts = std::map<std::string, std::map<std::string, uint64_t>>;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
Cache *instance_ = nullptr;
|
std::unique_ptr<Cache> instance_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace cache {
|
namespace cache {
|
||||||
void
|
void
|
||||||
init(const QString &user_id, QObject *parent)
|
init(const QString &user_id)
|
||||||
{
|
{
|
||||||
if (!instance_)
|
if (!instance_)
|
||||||
instance_ = new Cache(user_id, parent);
|
instance_ = std::make_unique<Cache>(user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cache *
|
Cache *
|
||||||
client()
|
client()
|
||||||
{
|
{
|
||||||
return instance_;
|
return instance_.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,7 +497,7 @@ ChatPage::bootstrap(QString userid, QString homeserver, QString token)
|
|||||||
http::client()->getOwnProfile();
|
http::client()->getOwnProfile();
|
||||||
http::client()->getOwnCommunities();
|
http::client()->getOwnCommunities();
|
||||||
|
|
||||||
cache::init(userid, this);
|
cache::init(userid);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cache::client()->setup();
|
cache::client()->setup();
|
||||||
|
@ -55,7 +55,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
setObjectName("MainWindow");
|
setObjectName("MainWindow");
|
||||||
|
|
||||||
// Initialize the http client.
|
// Initialize the http client.
|
||||||
http::init(this);
|
http::init();
|
||||||
|
|
||||||
restoreWindowSize();
|
restoreWindowSize();
|
||||||
|
|
||||||
|
@ -34,22 +34,22 @@
|
|||||||
#include "MatrixClient.h"
|
#include "MatrixClient.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
MatrixClient *instance_ = nullptr;
|
std::unique_ptr<MatrixClient> instance_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace http {
|
namespace http {
|
||||||
|
|
||||||
void
|
void
|
||||||
init(QObject *parent)
|
init()
|
||||||
{
|
{
|
||||||
if (!instance_)
|
if (!instance_)
|
||||||
instance_ = new MatrixClient(parent);
|
instance_ = std::make_unique<MatrixClient>();
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixClient *
|
MatrixClient *
|
||||||
client()
|
client()
|
||||||
{
|
{
|
||||||
return instance_;
|
return instance_.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user