Skip to content
Snippets Groups Projects
Verified Commit ff502f30 authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Initialize client lazily

This prevents a use after free in the coeurl logging, if we exit immediately.
parent bf68aa28
No related branches found
No related tags found
No related merge requests found
...@@ -28,22 +28,20 @@ Q_DECLARE_METATYPE(std::vector<std::string>) ...@@ -28,22 +28,20 @@ Q_DECLARE_METATYPE(std::vector<std::string>)
Q_DECLARE_METATYPE(std::vector<QString>) Q_DECLARE_METATYPE(std::vector<QString>)
Q_DECLARE_METATYPE(std::set<QString>) Q_DECLARE_METATYPE(std::set<QString>)
namespace {
auto client_ = std::make_shared<mtx::http::Client>();
}
namespace http { namespace http {
mtx::http::Client * mtx::http::Client *
client() client()
{ {
static auto client_ = std::make_shared<mtx::http::Client>();
return client_.get(); return client_.get();
} }
bool bool
is_logged_in() is_logged_in()
{ {
return !client_->access_token().empty(); return !client()->access_token().empty();
} }
void void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment