-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.8.4, 6.9.1, 6.10.0 Beta2
-
None
-
Windows 10 22H2, MSVC 2022 x64
-
b1c48db75 (dev), 6efdecd36 (6.10), 28cb8f65b (6.9)
See the attached example. CppObj is a QML_ELEMENT while CppBridge is a QML_SINGLETON.
It creates 3 CppObjs with JavaScriptOwnership and no parent:
Identifier | Comment |
---|---|
-1 | Instantiated declaratively in QML |
0 | Instantiated from C++, not stored |
1 | Instantiated from C++, stored in QML property |
Code
import QtQuick import QtQuick.Controls.Basic import JSOwnershipStudy Window { width: 400 height: 300 visible: true property CppObj objFromCpp: CppBridge.singleObj(1) // identifier == 1 CppObj { id: objFromQml } // identifier == -1 Component.onCompleted: { const orphanedObj = CppBridge.singleObj(0) // identifier == 0 } Button { text: "Collect Garbage" onClicked: gc() } }
Steps to reproduce
- Run the attached example
- Click the "Collect Garbage" button
- Close the window to quit
Outcomes
- (All versions) CppObj IDs -1 and 1 are destroyed upon quitting (Expected)
- (Qt 6.5) CppObj ID 0 is destroyed by the garbage collector (Expected)
- (Qt 6.8+) CppObj ID 0 is never destroyed (Not Expected)
Setting QV4_GC_TIMELIMIT=0 and QV4_MM_AGGRESSIVE_GC=1 does not help.
- relates to
-
QTBUG-139025 [Reg 6.5.9 -> 6.8.4] Lists of objects with JavaScriptOwnership, stored in var properties, are no longer destroyed
-
- In Progress
-
-
QTBUG-138944 List of objects with JavaScriptOwnership are not ref-counted correctly when assigned to ListView.model
-
- In Progress
-
-
QTBUG-139059 Generated code does not track objects on JavaScript stack
-
- Closed
-
- resulted in
-
QTBUG-139053 Re-design transfer of QObject ownership to JavaScript
-
- Open
-
For Gerrit Dashboard: QTBUG-138919 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
673208,2 | QmlCompiler: Ensure QObjects returned to AOT-compiled code are wrapped | tqtc/lts-6.8 | qt/tqtc-qtdeclarative | Status: NEW | +2 | 0 |