Commit 805b31cc authored by Gabriel Souza Franco's avatar Gabriel Souza Franco
Browse files

Use lazy global initialization of Config singleton

The eager initialization was triggering early construction of
Instance::sIdentifier, breaking akonaditest. The test runner overrides
the environment variable AKONADI_INSTANCE before initializing the
server. By statically constructing sIdentifier, the setup code is too
late to change the value, leading to an assertion failure.
parent 7a6c62e5
......@@ -11,7 +11,7 @@
using namespace Akonadi;
Config Config::sConfig{};
Q_GLOBAL_STATIC(Config, sConfig) // NOLINT(readability-redundant-member-init)
namespace {
......@@ -46,5 +46,10 @@ Config::Config()
void Config::setConfig(const Config &config)
{
sConfig = config;
*sConfig = config;
}
const Config &Config::get()
{
return *sConfig;
}
......@@ -14,12 +14,10 @@ namespace Akonadi
class Config
{
public:
explicit Config();
~Config() = default;
static const Config &get()
{
return sConfig;
}
static const Config &get();
struct PayloadCompression {
/**
......@@ -39,12 +37,7 @@ public:
protected:
explicit Config();
static void setConfig(const Config &config);
private:
static Config sConfig;
};
} // namespace Akonadi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment