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/group.cpp | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'options/group.cpp') diff --git a/options/group.cpp b/options/group.cpp index d710afad..a2169ae5 100644 --- a/options/group.cpp +++ b/options/group.cpp @@ -91,28 +91,4 @@ const std::shared_ptr group::ini_file() return std::make_shared(); } -bool group::operator==(const group& other) const -{ - for (const auto& kv : kvs) - { - const QVariant val = other.get(kv.first); - if (!other.contains(kv.first) || kv.second != val) - { - qDebug() << "bundle" << name << "modified" << "key" << kv.first << "-" << val << "<>" << kv.second; - return false; - } - } - - for (const auto& kv : other.kvs) - { - const QVariant val = get(kv.first); - if (!contains(kv.first) || kv.second != val) - { - qDebug() << "bundle" << name << "modified" << "key" << kv.first << "-" << kv.second << "<>" << val; - return false; - } - } - return true; -} - } -- cgit v1.2.3