aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltest
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmltest')
-rw-r--r--src/qmltest/SignalSpy.qml10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/qmltest/SignalSpy.qml b/src/qmltest/SignalSpy.qml
index 029003c70f..93fde00edb 100644
--- a/src/qmltest/SignalSpy.qml
+++ b/src/qmltest/SignalSpy.qml
@@ -45,6 +45,16 @@ Item {
id: spy
visible: false
+ Component.onDestruction: {
+ // We are potentially destroyed before the target object,
+ // and since only the sender (target) being destroyed destroys a connection
+ // in QML, and not the receiver (us/"spy"), we need to manually disconnect.
+ // When QTBUG-118166 is implemented, we can remove this.
+ let signalFunc = target ? target[signalName] : null
+ if (signalFunc)
+ signalFunc.disconnect(spy.qtest_activated)
+ }
+
TestUtil {
id: util
}