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

Qt Qml: sometimes properties expressions are evaluated twice during initialization

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 5.6.3, 5.7.1, 5.9.3, 5.10.0
    • Fix Version/s: 5.11.0 Beta 2
    • Labels:
      None
    • Environment:
      Tested on:

      Bug: Linux 5.9.3, 5.10,SailfishOS 5.6.3, iOS 5.7.1

      Works: Windows 5.5.1

      Description

       

      I think that example is self explanatory. getTmp1Value function is called twice during property initialization phase. It seems a regression - on Qt < 5.6 it works as expected - called once

      import QtQuick 2.0
      
      QtObject {
          property int tmp0: tmp1 + 1
          property int tmp1: getTmp1Value()
      
          function getTmp1Value() {
              console.log("getTmp1Value should be called only once");
              return 1;
          }
      }

       I emphasize that changing order of properties fixes the bug:

      property int tmp1: getTmp1Value()
      property int tmp0: tmp1 + 1
      

       

       

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              shausman Simon Hausmann
              Reporter:
              tolszak Tomasz Olszak
              Votes:
              3 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes