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

Inconsistent behaviour between qmlsc and JIT compiler when setting a property to "undefined"

    XMLWordPrintable

Details

    • da6680cb2 (dev), 104c90e88 (6.7), 49a62c410 (6.6), 2658ce482 (tqtc/lts-6.5), 058ecd5d9 (tqtc/lts-6.2)

    Description

      Code

      // TestClass.h
      class TestClass : public QObject
      {
          Q_OBJECT
          QML_ELEMENT
          Q_PROPERTY(qreal value READ value WRITE setValue RESET resetValue NOTIFY valueChanged FINAL)
      
          // ...
      };
      
      // Main.qml
      import QtQuick
      import QtQuick.Controls.Basic
      import ResetIssue
      
      ApplicationWindow {
          width: 640
          height: 480
          visible: true
      
          TestClass { id: testClass }
      
          Column {
              Button {
                  text: "Set"
                  onClicked: testClass.value = 999
              }
              Button {
                  text: "Call Reset Function"
                  onClicked: testClass.resetValue()
              }
              Button {
                  text: "Assign undefined value"
                  onClicked: testClass.value = undefined
                  // JIT: Calls reset function
                  // AOT: Calls setter function with NaN
              }
              Label {
                  text: "Value: " + testClass.value
              }
          }
      }
      

       

      Steps to reproduce

      1. Build and run the attached project
      2. Click "Set"
      3. Click "Call Reset Function"
      4. Click "Set"
      5. Click "Assign undefined value"
      6. Edit CMakeLists.txt to add "NO_CACHEGEN" to qt_add_qml_module(), and repeat the steps above

       

      Outcomes

      • Step #3 always calls resetValue() (expected)
      • Step #5 calls setValue() with NaN if qmlsc/qmlcachegen is enabled, but calls resetValue() if qmlsc/qmlcachegen is disabled (not expected)

      Attachments

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

        Activity

          People

            ulherman Ulf Hermann
            skoh-qt Sze Howe Koh
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews