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

[Reg 6.5 -> 6.7] Reference/Value nature of lists is inconsistent

XMLWordPrintable

    • Windows
    • 35630eef3 (dev)

      In some situations, a property of a QML registered c++ class (in the example called Bar :: p) is unexpectedly written, although it is not altered.

      This happens, when:

      • the property is assigned to a property of a QML component
      • the property is a QList of an enum type

      Please, see the attached example code.

       

      The unexpected writing happens when bar.p is assigned to foo.p and foo.p is modified. bar.p should stay unmodified, but it is changed.

      // Type exported from C++ via QML_ELEMENT
      Bar {
          id: bar
      
          onPChanged: {
              // If "foo" would overwrite bar's "p", the following lines would be reached
              // This is not expected - BUT does happen!
              console.log("Bar::onPChanged UNEXPECTEDLY from QML")
          }
      }
      
      Item {
          id: foo
          
          property var p: bar.p
      
          Component.onCompleted: foo.p.push(Bar.World) 
      }

       

      This does not happen, if the property (Bar :: p) is not a QList of enum types, but a QList of int or QString, for example.

        For Gerrit Dashboard: QTBUG-127957
        # Subject Branch Project Status CR V

            ulherman Ulf Hermann
            vertigo Christian Poms
            Votes:
            5 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes