Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
5.14.2, 5.15.0
Description
When creating an object with Component.createObject, then connecting to a signal on it and destroying it, qml will leak QQmlContext objects over time. Here's a minimal example:
import QtQuick 2.11 Item { id: root signal outer Component { id: comp Item { signal inner } } Timer{ repeat: true interval: 50 running: true onTriggered: { let obj = comp.createObject(root); root.outer.connect(obj.inner) //WORKAROUND //root.outer.disconnect(obj.inner) obj.destroy() gc() } } //"Objects are not destroyed //the instant destroy() is called, but are cleaned up sometime between the end //of that script block and the next frame (unless you specified a non-zero //delay)." /*Component.onCompleted: { while (true) { let obj = comp.createObject(root); root.outer.connect(obj.inner) obj.destroy() gc() } }*/ }
The signal to signal connection prevents the object from cleanup. Either disconnect should happen automatically or the documentation should mention, that disconnect is needed.
Attachments
Issue Links
- depends on
-
QTBUG-88248 QObject orphaned connections soft-leak
- Closed
- relates to
-
QTBUG-88587 QQuickWidget object stay in QML Engine cache after deletion
- Closed