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

False alarm about breaking delegate binding

    XMLWordPrintable

Details

    • ec79af7396fd695b25f8f7dba66e8048d54b953b

    Description

      I have a c++ model object (`controller`) that has a QVariantList property (`stepList`) which contains a list of c++ objects which are owned by c++.

      The steps are displayed using a repeater:

       

      QtQuick.Repeater {
          model: controller.stepList
      
          QtQuick.Text { 
              required property var modelData // set by repeater 
      
              text: modelData.stepNumber
          }
      }

       

      When my component gets destroyed, the repeater and the controller get destroyed (and with the controller the steps are destroyed too).

      When the step is destroyed, I get the following warning on my console:

       

      Writing to "modelData" broke the binding to the underlying model
      

      I believe this shouldn't be triggered from the repeater model getting destroyed.

       

      For people experiencing this issue, I managed to come up with a reasonably simple workaround by resetting the model on destruction. This also needs that the repeater is destructed before the controller object.

      QtQuick.Repeater {
          model: controller.stepList 
      
          QtQuick.Component.onDestruction: model=undefined
      
          QtQuick.Text {
              required property var modelData // set by repeater  
              text: modelData.stepNumber
          }
      }
      

       

       

      Attachments

        Issue Links

          Activity

            People

              ulherman Ulf Hermann
              janos_fl j h
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: