Whether returned object from Qt.createComponent needs to be destroyed?
Solved
QML and Qt Quick
-
var component = Qt.createComponent("SplashScreen.qml"); var obj = component.createObject(parent); if(obj === null) { obj.finished.connect(showHomePage); }
In the official example, no destroy.
-
@crawl-w Hi,
Using
destroy()
. The doc ofcreateObject()
say:Dynamically created instances can be deleted with the destroy() method. See Dynamic QML Object Creation from JavaScript for more information.
-
The JavaScript engine will indeed take ownership of the object created by Qt.create
ComponentObject. This is not documented specifically because in general, any object returned by a JavaScript function is normally managed by the garbage collector.
6/6