Commit 1ee96e982a6f93f88e276847b0bae4c5918fb7fb

Authored by Wiebe Cazemier
1 parent 1b3c90ae

Fix crash on config reload when there is no config

configfileparser.cpp
... ... @@ -445,5 +445,12 @@ void ConfigFileParser::loadFile(bool test)
445 445 }
446 446 }
447 447  
  448 +std::unique_ptr<Settings> ConfigFileParser::moveSettings()
  449 +{
  450 + std::unique_ptr<Settings> tmp = std::move(settings);
  451 + settings.reset(new Settings);
  452 + return tmp;
  453 +}
  454 +
448 455  
449 456  
... ...
configfileparser.h
... ... @@ -44,6 +44,8 @@ class ConfigFileParser
44 44 std::set<std::string> validKeys;
45 45 std::set<std::string> validListenKeys;
46 46  
  47 + std::unique_ptr<Settings> settings;
  48 +
47 49 void testKeyValidity(const std::string &key, const std::set<std::string> &validKeys) const;
48 50 void checkFileExistsAndReadable(const std::string &key, const std::string &pathToCheck, ssize_t max_size = std::numeric_limits<ssize_t>::max()) const;
49 51 void checkFileOrItsDirWritable(const std::string &filepath) const;
... ... @@ -51,7 +53,7 @@ public:
51 53 ConfigFileParser(const std::string &path);
52 54 void loadFile(bool test);
53 55  
54   - std::unique_ptr<Settings> settings;
  56 + std::unique_ptr<Settings> moveSettings();
55 57 };
56 58  
57 59 #endif // CONFIGFILEPARSER_H
... ...
mainapp.cpp
... ... @@ -628,7 +628,7 @@ void MainApp::loadConfig()
628 628 // Atomic loading, first test.
629 629 confFileParser->loadFile(true);
630 630 confFileParser->loadFile(false);
631   - settings = std::move(confFileParser->settings);
  631 + settings = confFileParser->moveSettings();
632 632  
633 633 if (settings->listeners.empty())
634 634 {
... ...