diff options
Diffstat (limited to 'options')
-rw-r--r-- | options/bundle.cpp | 6 | ||||
-rw-r--r-- | options/group.cpp | 13 | ||||
-rw-r--r-- | options/group.hpp | 1 |
3 files changed, 18 insertions, 2 deletions
diff --git a/options/bundle.cpp b/options/bundle.cpp index e4c0ffbd..482e46d1 100644 --- a/options/bundle.cpp +++ b/options/bundle.cpp @@ -1,6 +1,9 @@ #include "bundle.hpp" #include "value.hpp" +#include <QThread> +#include <QApplication> + using options::base_value; namespace options @@ -58,6 +61,9 @@ bool bundle::contains(const QString &name) const void bundle::save_deferred(QSettings& s) { + if (QThread::currentThread() != qApp->thread()) + qCritical() << "group::save - current thread not ui thread"; + if (group_name.size() == 0) return; diff --git a/options/group.cpp b/options/group.cpp index 94e111aa..a17f185c 100644 --- a/options/group.cpp +++ b/options/group.cpp @@ -2,6 +2,7 @@ #include "defs.hpp" #include <QStandardPaths> #include <QDir> + #include <QDebug> namespace options { @@ -48,7 +49,7 @@ void group::put(const QString &s, const QVariant &d) bool group::contains(const QString &s) const { - return kvs.count(s) != 0; + return kvs.find(s) != kvs.cend(); } QString group::ini_directory() @@ -64,7 +65,10 @@ QString group::ini_directory() QString group::ini_filename() { QSettings settings(OPENTRACK_ORG); - return settings.value(OPENTRACK_CONFIG_FILENAME_KEY, OPENTRACK_DEFAULT_CONFIG).toString(); + const QString ret = settings.value(OPENTRACK_CONFIG_FILENAME_KEY, OPENTRACK_DEFAULT_CONFIG).toString(); + if (ret.size() == 0) + return OPENTRACK_DEFAULT_CONFIG; + return ret; } QString group::ini_pathname() @@ -75,6 +79,11 @@ QString group::ini_pathname() return dir + "/" + ini_filename(); } +QString group::ini_combine(const QString& filename) +{ + return ini_directory() + QStringLiteral("/") + filename; +} + QStringList group::ini_list() { const auto dirname = ini_directory(); diff --git a/options/group.hpp b/options/group.hpp index f5b3e523..82b508af 100644 --- a/options/group.hpp +++ b/options/group.hpp @@ -26,6 +26,7 @@ public: static QString ini_directory(); static QString ini_filename(); static QString ini_pathname(); + static QString ini_combine(const QString& filename); static QStringList ini_list(); static std::shared_ptr<QSettings> ini_file(); |