summaryrefslogtreecommitdiffhomepage
path: root/options
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-08-20 11:46:42 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-08-20 11:57:58 +0200
commit109b6dd280e5cc6129f9ea739f1ab4b545cd593a (patch)
treefe736ab1432c9e0acd8d4f6242355d6219063de2 /options
parentac07604a12b4d4a08e19f5096f161649c85bd57d (diff)
options/connector: spew more warnings
Diffstat (limited to 'options')
-rw-r--r--options/connector.cpp54
-rw-r--r--options/connector.hpp1
-rw-r--r--options/value.hpp1
3 files changed, 40 insertions, 16 deletions
diff --git a/options/connector.cpp b/options/connector.cpp
index ba460b1f..c1bbce39 100644
--- a/options/connector.cpp
+++ b/options/connector.cpp
@@ -1,3 +1,4 @@
+#include "compat/util.hpp"
#include "connector.hpp"
#include "value.hpp"
@@ -6,37 +7,58 @@ namespace detail {
connector::~connector() {}
-void connector::on_value_destructed(const QString& name, const base_value* val)
+bool connector::on_value_destructed_impl(const QString& name, const base_value* val)
{
QMutexLocker l(get_mtx());
- auto it = connected_values.find(name);
-
- bool ok = false;
+ const bool ok = progn(
+ auto it = connected_values.find(name);
- if (it != connected_values.end())
- {
- std::vector<const base_value*>& values = (*it).second;
- for (auto it = values.begin(); it != values.end(); it++)
+ if (it != connected_values.end())
{
- if (*it == val)
+ std::vector<const base_value*>& values = (*it).second;
+ for (auto it = values.begin(); it != values.end(); it++)
{
- values.erase(it);
- ok = true;
- break;
+ if (*it == val)
+ {
+ values.erase(it);
+ return true;
+ }
}
}
- }
+ return false;
+ );
+
+ return ok;
+}
+
+
+
+void connector::on_value_destructed(const QString& name, const base_value* val)
+{
+ const bool ok = on_value_destructed_impl(name, val);
if (!ok)
- qWarning() << "connector: bundle destructed without creating;"
- << "name" << name
- << "ptr" << quintptr(val);
+ qWarning() << "options/connector: value destructed without creating;"
+ << "bundle"
+ << (val && val->b ? val->b->name() : "<NULL>")
+ << "value-name" << name
+ << "value-ptr" << quintptr(val);
}
void connector::on_value_created(const QString& name, const base_value* val)
{
QMutexLocker l(get_mtx());
+
+ if (on_value_destructed_impl(name, val))
+ {
+ qWarning() << "options/connector: value created twice;"
+ << "bundle"
+ << (val && val->b ? val->b->name() : "<NULL>")
+ << "value-name" << name
+ << "value-ptr" << quintptr(val);
+ }
+
auto it = connected_values.find(name);
if (it != connected_values.end())
diff --git a/options/connector.hpp b/options/connector.hpp
index ef9e4dbf..504c636d 100644
--- a/options/connector.hpp
+++ b/options/connector.hpp
@@ -22,6 +22,7 @@ class OPENTRACK_OPTIONS_EXPORT connector
void on_value_destructed(const QString& name, const base_value* val);
void on_value_created(const QString& name, const base_value* val);
+ bool on_value_destructed_impl(const QString& name, const base_value* val);
protected:
void notify_values(const QString& name) const;
diff --git a/options/value.hpp b/options/value.hpp
index f0ecf0c7..4ed61f1c 100644
--- a/options/value.hpp
+++ b/options/value.hpp
@@ -27,6 +27,7 @@ template<typename t> using value_type_t = typename value_type_traits<t>::type;
class OPENTRACK_OPTIONS_EXPORT base_value : public QObject
{
Q_OBJECT
+ friend class ::options::detail::connector;
public:
QString name() const { return self_name; }
base_value(bundle b, const QString& name) : b(b), self_name(name)