Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-9525

Item's onDestroyed singnal called too late, element already deleted

XMLWordPrintable

      The Item's onDestroyed signal needs to be called while the element still
      exists to allow cleanup based on the item's reference. This does not appear
      to be the case, at least when the item is destroyed as a result of the QML app
      being reloaded.
      I.e. running this code

      Rectangle {
          id: rect
          color:"red"
      
          Component.onCompleted: print("Created " + rect.toString());
          onDestroyed: print("Destroyed " + rect.toString());   // results in "Result of expression 'rect' [undefined] is not an object."
      }
      

      then pressing Ctrl+R in the QML viewer to reload the application, rect is already
      "undefined" when onDestroyed is called. Is this also the case when e.g. a ListView
      deallocates a delegate?

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            martjone Martin Jones (closed Nokia identity) (Inactive)
            mathiasm Mathias Malmqvist
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes