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

Excessive calls to the default constructor of QML value types

XMLWordPrintable

      Let's make a slight modification to the example at QTBUG-139463:

      import QtQuick
      import ValueTypeStudy
      
      Window {
          width: 640
          height: 480
          visible: true
      
          property myStructuredType t: ({
              number: 42,
              truth: true
          })
      
          Component.onCompleted: {
              console.log("=== Component Complete ===")
              console.log(t.toString())
          }
      }
      

      There are no more compiler warnings now. However, other issues stand out.

       

      Outcomes

      Constructing: 0 false
      Constructing: 0 false
      Setting number: 42
      Setting truth: true
      qml: === Component Complete ===
      Constructing: 0 false
      qml: myStructuredType(42, true)
      
      • At initialization, the default constructor is called twice.
        • Note: It is only called once if AOT compilation is suppressed, e.g. by adding NO_CACHEGEN or by adding an invalid property (as QTBUG-139463 did)
      • At completion, the default constructor is called when referencing an existing instance: console.log(t.toString())

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

            qtqmlteam Qt Qml Team User
            skoh-qt Sze Howe Koh
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes