From f65d6ea0d7ca7de7a6c7538612731b11889086fb Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sat, 4 Jan 2020 21:12:06 +0200 Subject: Fix configuration not being read unless explicitly specified --- src/settings.h.in | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/settings.h.in') diff --git a/src/settings.h.in b/src/settings.h.in index a4b5159..88fbcf5 100644 --- a/src/settings.h.in +++ b/src/settings.h.in @@ -4,26 +4,29 @@ #include #include -inline void init_conf(const std::string &path) +inline const std::string init_conf(const std::string &path) { + auto value_map = 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; }(); - auto value_map = std::make_unique>>({ - @__DEFAULT_CFG__ - }); - std::fstream fs; - fs.open(path, std::fstream::in); + fs.open(cfgpath, std::fstream::in); if(fs.is_open()) { value_map->read(fs); fs.close(); } Configuration::move_global(std::move(value_map)); + return cfgpath; } -- cgit v1.2.1