Initialize client lazily
This prevents a use after free in the coeurl logging, if we exit immediately.
This commit is contained in:
parent
bf68aa28d8
commit
ff502f306c
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user