Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

qml root deleted on startup

$
0
0
Usually there’ll be a signal handler or something which is invoked prior to the point that object creation completes (or more correctly, prior to the point where all of the first-time-binding-evaluations for the object, have completed). During that time, there is a window where an object can be marked for destruction via an explicit .destroy(), or due to garbage collection if an object isn’t referenced in a JS var and you call gc() manually or the JS engine decides it needs to clean stuff up. In Qt5, significant effort was expended to stop this from occurring (which is why the QQmlData – better name QQmlObjectPrivate – class gained a bunch of flags like isRootObjectInComponent / isQueuedForDeletion / etc etc), and so you shouldn’t have this problem in Qt5. In Qt4, a simple work around (if it is indeed a gc issue) is to have a .pragma library js resource imported by your root component, which contains: // stopgc.js .pragma library   var stopRootObjectGc = null function storeReference(obj) { stopRootObjectGc = obj } Then in your QML have something like: import "stopgc.js" as StopGC   Item {     id: root     Component.onCompleted: { StopGC.storeReference(root) } } If, on the otherhand, you are somehow manually deleteLater()ing the object, or destroy()ing it, then this will not help. Cheers, Chris.

Viewing all articles
Browse latest Browse all 4972

Trending Articles