From 39169acf3bc2bc43cc32a6455d43e9588765c84a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 25 Aug 2016 11:58:24 +0200 Subject: options: use non-generic comparison for bundle modification check The generic QVariant comparison works badly for QList. Create a comparator between two QVariants for base_value in value ctor, using QVariant::value which returns right results once it's converted to tp. If a value was registered for a name in a bundle, use that comparator as the comparator for that name. In case conflicting value types were registered always use generic comparison for that name. std::type_index needs to be used here since value can be instantiated in different modules (libraries), resulting in different value for the comparator function pointer. Move group::operator== to bundle type to avoid circular include for connector.h. Also use element_type more consistently in value. --- options/connector.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'options/connector.hpp') diff --git a/options/connector.hpp b/options/connector.hpp index b9b1259f..6aba79e2 100644 --- a/options/connector.hpp +++ b/options/connector.hpp @@ -2,6 +2,10 @@ #include #include +#include +#include +#include +#include #include #include #include @@ -18,7 +22,10 @@ class OPENTRACK_OPTIONS_EXPORT connector { friend class ::options::base_value; - std::map> connected_values; + using value_vec = std::vector; + using comparator = bool(*)(const QVariant&, const QVariant&); + using tt = std::tuple; + std::map connected_values; void on_value_destructed(const QString& name, const base_value* val); void on_value_created(const QString& name, const base_value* val); @@ -33,6 +40,8 @@ public: connector(); virtual ~connector(); + bool is_equal(const QString& name, const QVariant& val1, const QVariant& val2) const; + connector(const connector&) = default; connector& operator=(const connector&) = default; connector(connector&&) = default; -- cgit v1.2.3