Initialize client lazily

This prevents a use after free in the coeurl logging, if we exit immediately.
This commit is contained in:
Nicolas Werner 2021-11-24 05:20:27 +01:00
parent bf68aa28d8
commit ff502f306c
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
1 changed files with 2 additions and 4 deletions

View File

@ -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