diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-07-08 12:07:13 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-07-10 15:07:12 +0200 |
commit | bbfecdee1e2952c401e9c5ac6e16adc2428fb2dc (patch) | |
tree | 4b877d63b50606930bbac7416b3d164ae69cb70a /tests/auto | |
parent | be1ce6b26909256e62c2b39e4de9f8f79d070937 (diff) |
Significantly improve performance of binding evaluation
Avoid any QVariant or type dependent code in the cpp files.
Instead, let the binding wrapper determine if the value
has changed and return true/false accordingly.
This required also some reworking of the guard mechanism
for notified properties, where the guard function wrapper
now calls first the binding evaluation function and then
passes the result to the guard.
Change-Id: I350d07a508ccc0c5db7054a0efa4f270b6a78ec3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp index f14ba78b02..bac25e02b0 100644 --- a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp +++ b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp @@ -622,18 +622,20 @@ void tst_QProperty::genericPropertyBinding() { QUntypedPropertyBinding doubleBinding(QMetaType::fromType<double>(), - [](const QMetaType &, void *) -> void { + [](const QMetaType &, void *) -> bool { Q_ASSERT(false); + return true; }, QPropertyBindingSourceLocation()); QVERIFY(!property.setBinding(doubleBinding)); } QUntypedPropertyBinding intBinding(QMetaType::fromType<int>(), - [](const QMetaType &metaType, void *dataPtr) -> void { + [](const QMetaType &metaType, void *dataPtr) -> bool { Q_ASSERT(metaType.id() == qMetaTypeId<int>()); int *intPtr = reinterpret_cast<int*>(dataPtr); *intPtr = 100; + return true; }, QPropertyBindingSourceLocation()); QVERIFY(property.setBinding(intBinding)); @@ -648,9 +650,10 @@ void tst_QProperty::genericPropertyBindingBool() QVERIFY(!property.value()); QUntypedPropertyBinding boolBinding(QMetaType::fromType<bool>(), - [](const QMetaType &, void *dataPtr) -> void { + [](const QMetaType &, void *dataPtr) -> bool { auto boolPtr = reinterpret_cast<bool *>(dataPtr); *boolPtr = true; + return true; }, QPropertyBindingSourceLocation()); QVERIFY(property.setBinding(boolBinding)); |