[Interest] How do I clean up items in the QtQuick2 scenegraph?

Sletta Gunnar Gunnar.Sletta at digia.com
Wed Jun 26 08:19:43 CEST 2013

On Jun 26, 2013, at 7:00 AM, Preet <prismatic.project at gmail.com> wrote:

> I have a couple of custom QQuickItems that I'd like to be destroyed before the application exits if they are present in the scene. 
> The ~QQuickItem() destructors aren't called unless I explicitly call 
>     delete myQQuickView;

They are, but if they are instantiated in QML, they will be collected by the V8 GC at a later time, so it doesn't happen right away. In some cases, it can take quite a while.

> I call delete from the main thread, but I'm worried about what goes on with the scene graph rendering thread when I do this. Is deleting QQuickView from the main thread safe? If not, is there a way of stopping all rendering activity so I can delete QQuickView safely?

It is perfectly safe to delete the QQuickView on the GUI thread. This is what every Qt Quick 2 based app does :)

Internally, the QQuickView (QQuickWindow actually) will block the GUI until the rendering is complete and the scene graph and its rendering thread has gracefully shut down.


> Preet
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

More information about the Interest mailing list