aboutsummaryrefslogtreecommitdiff
path: root/lib/configuration/configuration.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/configuration/configuration.cpp')
-rw-r--r--lib/configuration/configuration.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/configuration/configuration.cpp b/lib/configuration/configuration.cpp
index 66617ed..d11b342 100644
--- a/lib/configuration/configuration.cpp
+++ b/lib/configuration/configuration.cpp
@@ -10,19 +10,18 @@
#include <algorithm>
#include <fstream>
#include <iostream>
-#include <sstream>
#include <stdexcept>
#ifndef NO_QT_SPEC
#include <QStandardPaths>
#endif
-static Configuration *s_conf = nullptr;
+static const Configuration *s_conf = nullptr;
Configuration::Configuration()
: use_global(true)
{
- if(!s_conf) {
+ if(s_conf == nullptr) {
throw std::runtime_error("Trying to use default Configuration, but none has been set!");
}
}
@@ -139,8 +138,7 @@ void Configuration::read(std::basic_istream<char> &input)
void Configuration::setValue(const std::string &key, const std::string &value)
{
if(use_global) {
- s_conf->setValue(key, value);
- return;
+ throw std::runtime_error("Global configuration is read-only!");
}
if(this->count(key) == 0) {
@@ -167,7 +165,7 @@ bool Configuration::make_global()
return true;
}
-Configuration *Configuration::instance()
+const Configuration *Configuration::instance()
{
return s_conf;
}