Correctly tearing down a QQuickView- derived window



  • Hi,

    I have a window which will be displayed to the user on a regular basis, and I'm using a class derived from QQuickView, setting the source property in the constructor.

    I was having problems when my windows was supposed to be displayed for the second time, my program would crash without any warning. More specifically, the only output I would get in the output window was:

    The program has unexpectedly finished.

    Initially, the plan was to call setSource() each time the window would be displayed, in order to ensure all timers etc. would be reset for the second time. When these problems occurred, I switched over to adding a JavaScript function in my .qml file, which took care of resetting everything, and only calling setSource once (at startup), but the problem didn't go away, now I got this error:

    ASSERT failure in QSGNode::appendChildNode: "QSGNode already has a parent", file scenegraph\coreapi\qsgnode.cpp, line 404

    Finally, I decided to throw away my object each time after being done using it (basically by calling delete on the object, I also tried calling close() and/or destroy() before that), and re-create it the next time the window should be displayed. But that gives me an error when I try to destroy my QQuickView-derived object for the first time, with the following assertion:

    ASSERT: "context() && engine()" in file qml\qqmlboundsignal.cpp, line 140

    So, what is the proper method to display the same window repeatedly? Or what is the proper method to correctly destroy such an object?

    Best regards,
    Daniel


  • Moderators

    Try calling ::deleteLater().



  • Although this is an old thread, I wanted to remark that sierdzio's reply helped me at least with the part about

    ASSERT: “context() && engine()” in file qml\qqm.....

    in the above post. Calling deleteLater() on the object created by component.create() fixed my issues.



  • Although this is an old thread, I wanted to remark that sierdzio's reply helped me at least with the part about

    ASSERT: “context() && engine()” in file qml\qqm.....

    in the above post. Calling deleteLater() on the object created by component.create() fixed my issues.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.