summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp
index 41cf60b55f..74a81cc93b 100644
--- a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp
+++ b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp
@@ -73,6 +73,7 @@ private slots:
void notifiedPropertyWithOldValueCallback();
void notifiedPropertyWithGuard();
void typeNoOperatorEqual();
+ void bindingValueReplacement();
};
void tst_QProperty::functorBinding()
@@ -1058,6 +1059,34 @@ void tst_QProperty::typeNoOperatorEqual()
QVERIFY(u1.changedCalled);
}
+
+struct Test {
+ void notify() {};
+ bool bindText(int);
+ bool bindIconText(int);
+ QProperty<int> text;
+ QNotifiedProperty<int, &Test::notify, &Test::bindIconText> iconText;
+};
+
+bool Test::bindIconText(int) {
+ Q_UNUSED(iconText.value()); // force read
+ if (!iconText.hasBinding()) {
+ iconText.setBinding(this, [=]() { return 0; });
+ }
+ return true;
+}
+
+void tst_QProperty::bindingValueReplacement()
+{
+ Test test;
+ test.text = 0;
+ test.bindIconText(0);
+ test.iconText.setValue(&test, 42); // should not crash
+ QCOMPARE(test.iconText.value(), 42);
+ test.text = 1;
+ QCOMPARE(test.iconText.value(), 42);
+}
+
QTEST_MAIN(tst_QProperty);
#include "tst_qproperty.moc"