From dd277842571ade5f78b33171648356a56fec400a Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Tue, 23 Jun 2020 17:16:35 +0300 Subject: Fix compiler warnings in Configuration --- src/settings.h.in | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src/settings.h.in') diff --git a/src/settings.h.in b/src/settings.h.in index 88fbcf5..605288e 100644 --- a/src/settings.h.in +++ b/src/settings.h.in @@ -4,29 +4,28 @@ #include #include -inline const std::string init_conf(const std::string &path) +inline auto init_conf(const std::string &path) { - auto value_map = std::make_unique>>({ + struct { + std::string path; + std::unique_ptr ptr; + } conf; + + conf.ptr = std::make_unique>>({ @__DEFAULT_CFG__ }); - const std::string cfgpath = [&]() { - if(path.empty()) - return value_map->value("poi.cfg.path").value(); - - auto p = path; - if(p.front() == '~') - p.replace(0, 1, QStandardPaths::writableLocation(QStandardPaths::HomeLocation).toStdString()); - return p; - }(); + conf.path = path.empty() ? conf.ptr->value("poi.cfg.path").value() : path; + if(conf.path.front() == '~') { + conf.path.replace(0, 1, QStandardPaths::writableLocation(QStandardPaths::HomeLocation).toStdString()); + }; std::fstream fs; - fs.open(cfgpath, std::fstream::in); + fs.open(conf.path, std::fstream::in); if(fs.is_open()) { - value_map->read(fs); + conf.ptr->read(fs); fs.close(); } - Configuration::move_global(std::move(value_map)); - return cfgpath; + return conf; } -- cgit v1.2.1