summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/kernel')
-rw-r--r--tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp
index 21e0955ba5..472ba6031f 100644
--- a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp
+++ b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp
@@ -33,6 +33,13 @@
using namespace QtPrivate;
+
+struct DtorCounter {
+ static inline int counter = 0;
+ bool shouldIncrement = false;
+ ~DtorCounter() {if (shouldIncrement) ++counter;}
+};
+
class tst_QProperty : public QObject
{
Q_OBJECT
@@ -43,6 +50,7 @@ private slots:
void bindingWithDeletedDependency();
void recursiveDependency();
void bindingAfterUse();
+ void bindingFunctionDtorCalled();
void switchBinding();
void avoidDependencyAllocationAfterFirstEval();
void boolProperty();
@@ -201,6 +209,20 @@ void tst_QProperty::bindingAfterUse()
QCOMPARE(QPropertyBindingDataPointer::get(propWithBindingLater).observerCount(), 1);
}
+void tst_QProperty::bindingFunctionDtorCalled()
+{
+ DtorCounter dc;
+ {
+ QProperty<int> prop;
+ prop.setBinding([dc]() mutable {
+ dc.shouldIncrement = true;
+ return 42;
+ });
+ QCOMPARE(prop.value(), 42);
+ }
+ QCOMPARE(DtorCounter::counter, 1);
+}
+
void tst_QProperty::switchBinding()
{
QProperty<int> first(1);