Important: Please read the Qt Code of Conduct -

How to do delete later in QML JavaScript?

  • I have a VideoThumbnail class inherits from QQuickItem, used in QML.
    VideoThumbnail has a callback thread which may post update event while
    the VideoThumbnail object is being destroyed, this race condition could incur crash.
    From what I read, deleteLater is needed, since JavaScript cannot call deleteLater
    directly, I create a Q_INVOKABLE method say DeleteMeLater in VideoThumbnail class
    and call deleteLater in the method.
    In QML JavaScript, it looks like
    VideoThumbnail {
    id: videoThumbnail

    Has anyone here done this before and could provide suggestions?
    Also is Component.onDestruction DirectConnection? and I assume destruction is emitted
    before any destruction starts?

    Delayed destroy is not the solution I am looking for.


Log in to reply