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

QQC2: Object destroyed during incubation

    XMLWordPrintable

Details

    • numerous

    Description

      Using customized controls in item views or asynchronous loader often leads to "Object destroyed during incubation" or "Error creating delegate". The problem occurs with basically any control when replacing the default background, content item, or any other building block with a custom one. Controls cleanup the old default content, which leads to a "Object destroyed during incubation" -error, and then the incubation of the whole control fails.

      In item views the problem occurs occasionally, leading to missing delegate instances (QML VisualDataModel: Error creating delegate):

      import QtQuick 2.6
      import QtQuick.Controls 2.0
      
      ApplicationWindow {
          visible: true
          width: 640
          height: 480
      
          GridView {
              id: gridThing;
              anchors.fill: parent;
              cellWidth: 75;
              cellHeight: 75;
              model: 500;
      
              delegate: Button {
                  id: control
                  text: "Test"
                  width: gridThing.cellWidth;
                  height: gridThing.cellHeight;
                  background: Rectangle {
                      implicitHeight: 20;
                      implicitWidth: 20;
                      color: "red";
                      width: control.width;
                      height: control.height;
                      x: 0;
                      y: 0;
                  }
              }
          }
      }
      

      In asynchronous loaders the issue is 100% reproducible with certain control structures:

      import QtQuick 2.6
      import QtQuick.Controls 2.0
      
      ApplicationWindow {
          id: root
          visible : true
          width   : 640
          height  : 480
      
          property bool  triggerTheBug: true // Swap this to see a normal display of the ComboBox
      
          StackView {
              id: myStackView
              anchors.fill: parent
              initialItem: Loader {
                  anchors.fill: parent
                  asynchronous    : triggerTheBug
                  sourceComponent :
                      ComboBox { popup      : Popup{} }         // BUG
                  //ComboBox { background : Rectangle{} }     // BUG
                  //ComboBox { contentItem: Rectangle{} }     // BUG
                  //ComboBox { delegate   : ItemDelegate{} }  // NO BUG
              }
          }
      }
      

      Under the hood, the problem is that QQmlIncubator + QQmlObjectCreator + QQmlVMEGuard tracks all instantiated child objects using QPointer and doesn't like that any of them gets destroyed during the incubation process. Calling deleteLater() is not sufficient, because it would not be synchronized with the incubation controller.

      Attachments

        Issue Links

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

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              taipan BogDan Vatra
              Votes:
              79 Vote for this issue
              Watchers:
              112 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes