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

context overwritting without a warning is bad

    XMLWordPrintable

Details

    Description

      import QtQuick 2.2
      import QtQuick.Controls 1.1
      
      ApplicationWindow {
          visible: true
          width: 640
          height: 480
      
          Item {
              id: style
              property color mySpecialColor: "#0000ff"
          }
          Text{
              Component.onCompleted: print("just the Text: " + style.mySpecialColor)
          }
          Item {
              Component.onCompleted: print("inside Item: " + style.mySpecialColor)
              Text{
                  Component.onCompleted: print("inside Item/Text: " + style.mySpecialColor)
              }
          }
          Component {
              id: myDelegate
              Item {
                  Component.onCompleted: print("inside Component: " + style.mySpecialColor)
                  Text{
                      Component.onCompleted: print("inside Component/Text: " + style.mySpecialColor)
                  }
              }
      
          }
          Loader{
              sourceComponent: myDelegate
              anchors.centerIn: parent
          }
      
      }
      
      • Output is:
        qml: inside Component: #0000ff
        qml: inside Component/Text: undefined
        qml: inside Item: #0000ff
        qml: inside Item/Text: #0000ff
        qml: just the Text: #0000ff
        

      You see the "undefined" output? This comes because Text has a property style. One strange thing is that this behaves different if that is in a component or not.
      The other strange thing is that the QML parser does not give me a warning about ambiguous values. Is that possible?

      Attachments

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

        Activity

          People

            tjenssen Tim Jenssen
            tjenssen Tim Jenssen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes