Initialize client lazily

This prevents a use after free in the coeurl logging, if we exit immediately.
pull/835/head
Nicolas Werner 3 years ago
parent bf68aa28d8
commit ff502f306c
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
  1. 6
      src/MatrixClient.cpp

@ -28,22 +28,20 @@ Q_DECLARE_METATYPE(std::vector<std::string>)
Q_DECLARE_METATYPE(std::vector<QString>)
Q_DECLARE_METATYPE(std::set<QString>)
namespace {
auto client_ = std::make_shared<mtx::http::Client>();
}
namespace http {
mtx::http::Client *
client()
{
static auto client_ = std::make_shared<mtx::http::Client>();
return client_.get();
}
bool
is_logged_in()
{
return !client_->access_token().empty();
return !client()->access_token().empty();
}
void

Loading…
Cancel
Save