summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qproperty.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2020-04-14 11:03:11 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2020-04-17 11:24:10 +0200
commitf395cedc5b7c5f0aa55387e906e4ad420f887533 (patch)
tree8e0941d3473a3c048dee2ff63e3088121df275ae /src/corelib/kernel/qproperty.h
parent4857f0ebd7f4ea422f7a5dc721f0204390adddbb (diff)
Simplify signature of untyped property bindings
Instead of requiring the implementation to do the compare dance, let's do this in the library. This reduces the amount of duplicated code slightly and makes it easier to generate binding code from qml files. Change-Id: Ia3b16cf9769e74d076b669efe4119ab84af3cdf0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel/qproperty.h')
-rw-r--r--src/corelib/kernel/qproperty.h12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h
index 8f050327d5..e43f59053d 100644
--- a/src/corelib/kernel/qproperty.h
+++ b/src/corelib/kernel/qproperty.h
@@ -117,10 +117,8 @@ private:
class Q_CORE_EXPORT QUntypedPropertyBinding
{
public:
- // Returns either a boolean to indicate value change or an error.
- using BindingEvaluationResult = std::variant<bool, QPropertyBindingError>;
- // returns true if value changed, false if the binding evaluation lead to the same value as the property
- // already has.
+ using BindingEvaluationResult = QPropertyBindingError;
+ // writes binding result into dataPtr
using BindingEvaluationFunction = std::function<BindingEvaluationResult(const QMetaType &metaType, void *dataPtr)>;
QUntypedPropertyBinding();
@@ -160,13 +158,11 @@ class QPropertyBinding : public QUntypedPropertyBinding
if (auto valuePtr = std::get_if<PropertyType>(&result)) {
PropertyType *propertyPtr = reinterpret_cast<PropertyType *>(dataPtr);
- if (*propertyPtr == *valuePtr)
- return false;
*propertyPtr = std::move(*valuePtr);
- return true;
+ return {};
}
- return false;
+ return {};
}
};