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

Dynamically created Objects cannot be destroyed because indestructible flag is set

    XMLWordPrintable

Details

    Description

      The following Code throws the error message "invalid attempt to destroy() an indestructible object":

      import QtQuick 2.0
      
      Rectangle {
          id: appWindow
      
      
          width: 320; height: 480
          Rectangle{
              id: contentArea
              function initialize()
              {
                  var rectangles = new Array(4);
                  var c = Qt.createComponent("local.qml");
                  if (c.status == Component.Ready)
                  {
                      rectangles[0] = c.createObject(contentArea);
                      console.log(c.createObject(contentArea));
                      rectangles[0].height = 400;
                      rectangles[0].width = 320;
                      rectangles[0].visible = false;
                  }
                  rectangles[0].destroy();
              }
      
              width:  parent.width
              height: parent.height - 60
              x: 0;
              y: 60
              color: "#00000f"
              Component.onCompleted: {
                  console.log("EVENT:onCompleted")
                  contentArea.initialize();
                  contentInteractionArea.drag.target = contentArea.rectangles[0];
                  drag.axis =  Drag.XAxis;
              }
      
              MouseArea{
                  id: contentInteractionArea
                  anchors.fill: parent
                  z: 100
                  onClicked: {}
      
              }
          }
      }
      

      Content of local.qml:

      import QtQuick 2.0
      
      Rectangle{
          id: rect
          color: "#ff00ff"
          property string name: "rect"
      }
      

      Works fine under Qt 4

      Attachments

        Issue Links

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

          Activity

            People

              chriadam Christopher Adams (closed Nokia identity) (Inactive)
              vonschwe Clemens von Schwerin
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes