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

Readonly properties are writable

    XMLWordPrintable

Details

    Description

      The "readonly" keyword does not work anymore. Seems like it affects all types of properties.
      The readonly properties are writable and no error messages are given.
      The bug was noticed in 5.9.0, but maybe it started in earlier Qt versions.
      The example from the "Read-Only Properties" section at http://doc.qt.io/qt-5/qtqml-syntax-objectattributes.html fails, as shown in the code below.
      Marking it as P1 bug, but it should probably be raised to P0, because it may lead to undefined or unexpected behavior of Qml code that uses "readonly" properties.

      import QtQuick 2.8
      import QtQuick.Window 2.2
      
      Window {
          visible: true
      
          Item {
              readonly property int someNumber: 10
      
              Component.onCompleted: {
                  someNumber = 20  // "doesn't work, causes an error" <--- Not really, works like a charm!
                  console.log(someNumber)
                  // output: qml: 20
              }
          }
      }

      Attachments

        Issue Links

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

          Activity

            People

              shausman Simon Hausmann
              j0hnny j0hnny
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes