diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index 965939a1fc..f1c8adb8a0 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -744,7 +744,10 @@ void QPropertyObserverPointer::noSelfDependencies(QPropertyBindingPrivate *bindi // See also comment in notify() while (observer) { if (QPropertyObserver::ObserverTag(observer->next.tag()) == QPropertyObserver::ObserverNotifiesBinding) - Q_ASSERT(observer->binding != binding); + if (observer->binding == binding) { + qCritical("Property depends on itself!"); + break; + } observer = observer->next.data(); } diff --git a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp index fb99ed1880..6e63792a11 100644 --- a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp +++ b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp @@ -113,6 +113,8 @@ private slots: void notify(); void bindableInterfaceOfCompatPropertyUsesSetter(); + + void selfBindingShouldNotCrash(); }; void tst_QProperty::functorBinding() @@ -1847,6 +1849,13 @@ void tst_QProperty::bindableInterfaceOfCompatPropertyUsesSetter() QCOMPARE(obj.setCompatCalled, 1); } +void tst_QProperty::selfBindingShouldNotCrash() +{ + QProperty i; + i.setBinding([&](){ return i+1; }); + QVERIFY(i.binding().error().hasError()); +} + QTEST_MAIN(tst_QProperty); #undef QT_SOURCE_LOCATION_NAMESPACE