diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2020-04-14 11:03:11 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2020-04-17 11:24:10 +0200 |
commit | f395cedc5b7c5f0aa55387e906e4ad420f887533 (patch) | |
tree | 8e0941d3473a3c048dee2ff63e3088121df275ae /tests/auto/corelib/kernel | |
parent | 4857f0ebd7f4ea422f7a5dc721f0204390adddbb (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 'tests/auto/corelib/kernel')
-rw-r--r-- | tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp index cc04c2f1b5..488ecacb8d 100644 --- a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp +++ b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp @@ -617,22 +617,20 @@ void tst_QProperty::genericPropertyBinding() { QUntypedPropertyBinding doubleBinding(QMetaType::fromType<double>(), - [](const QMetaType &, void *) -> bool { + [](const QMetaType &, void *) -> QUntypedPropertyBinding::BindingEvaluationResult { Q_ASSERT(false); - return false; + return QPropertyBindingError::NoError; }, QPropertyBindingSourceLocation()); QVERIFY(!property.setBinding(doubleBinding)); } QUntypedPropertyBinding intBinding(QMetaType::fromType<int>(), - [](const QMetaType &metaType, void *dataPtr) -> bool { + [](const QMetaType &metaType, void *dataPtr) -> QUntypedPropertyBinding::BindingEvaluationResult { Q_ASSERT(metaType.id() == qMetaTypeId<int>()); int *intPtr = reinterpret_cast<int*>(dataPtr); - if (*intPtr == 100) - return false; *intPtr = 100; - return true; + return QPropertyBindingError::NoError; }, QPropertyBindingSourceLocation()); QVERIFY(property.setBinding(intBinding)); @@ -647,12 +645,10 @@ void tst_QProperty::genericPropertyBindingBool() QVERIFY(!property.value()); QUntypedPropertyBinding boolBinding(QMetaType::fromType<bool>(), - [](const QMetaType &, void *dataPtr) -> bool { + [](const QMetaType &, void *dataPtr) -> QUntypedPropertyBinding::BindingEvaluationResult { auto boolPtr = reinterpret_cast<bool *>(dataPtr); - if (*boolPtr) - return false; *boolPtr = true; - return true; + return {}; }, QPropertyBindingSourceLocation()); QVERIFY(property.setBinding(boolBinding)); |