summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/kernel/qproperty_p.h1
-rw-r--r--tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp16
2 files changed, 17 insertions, 0 deletions
diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h
index a3a9072793..4a80754ec8 100644
--- a/src/corelib/kernel/qproperty_p.h
+++ b/src/corelib/kernel/qproperty_p.h
@@ -286,6 +286,7 @@ public:
bool isUpdating() {return updating;}
void setSticky(bool keep = true) {m_sticky = keep;}
bool isSticky() {return m_sticky;}
+ void scheduleNotify() {pendingNotify = true;}
QPropertyBindingPrivate(QMetaType metaType, const QtPrivate::BindingFunctionVTable *vtable,
const QPropertyBindingSourceLocation &location, bool isQQmlPropertyBinding=false)
diff --git a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp
index 877896407a..0f89ccee8b 100644
--- a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp
+++ b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp
@@ -118,6 +118,7 @@ private slots:
void selfBindingShouldNotCrash();
void qpropertyAlias();
+ void scheduleNotify();
};
void tst_QProperty::functorBinding()
@@ -2015,6 +2016,21 @@ void tst_QProperty::qpropertyAlias()
QVERIFY(!alias.isValid());
}
+void tst_QProperty::scheduleNotify()
+{
+ int notifications = 0;
+ QProperty<int> p;
+ QCOMPARE(p.value(), 0);
+ const auto handler = p.addNotifier([&](){ ++notifications; });
+ QCOMPARE(notifications, 0);
+ QPropertyBinding<int> b([]() { return 0; }, QPropertyBindingSourceLocation());
+ QPropertyBindingPrivate::get(b)->scheduleNotify();
+ QCOMPARE(notifications, 0);
+ p.setBinding(b);
+ QCOMPARE(notifications, 1);
+ QCOMPARE(p.value(), 0);
+}
+
QTEST_MAIN(tst_QProperty);
#undef QT_SOURCE_LOCATION_NAMESPACE