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

Event handler vs binding / qmlsc crash for 6.5

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P1: Critical
    • 6.5
    • 6.4.1, 6.5
    • QML: Compiler

    Description

      In the following example, the onCompleted handler is misinterpreted:

      import QtQuick
      
      Window {
          id: win
          width: 640
          height: 480
          visible: true
          title: "Wohooooo"
      
          property Item foo: Rectangle {
              id: r1
              onColorChanged: () => console.log("R1: " + r1.color)
          }
          property Item bar: Rectangle {
              id: r2
              onColorChanged: () => console.log("R2: " + r2.color)
          }
      
          // Works
          Item {
              Component.onCompleted: ((win.foo as Rectangle).color = "red") && ((win.bar as Rectangle).color = "blue")
          }
      
          // Compiles without errors for 6.4.1, crashes qmlsc for 6.5
          Item {
              Component.onCompleted: () => {
                  (win.foo as Rectangle).color = "black"
                  (win.bar as Rectangle).color = "white"
              }
          }
      
          // Compiles wit error for 6.4.1, crashes qmlsc for 6.5
          Item {
              Component.onCompleted: {
                  (win.foo as Rectangle).color = "green"
                  (win.bar as Rectangle).color = "yellow"
              }
          }
      
          // Works 
          Item {
              Component.onCompleted: {
                  (win.foo as Rectangle).color = "deep";
                  (win.bar as Rectangle).color = "purple"
              }
          }
      }
      

      .

      Compiler output for 6.4.1:

      Error: main.qml:37:25: Could not compile binding for onCompleted: Instruction "generate_CallValue" not implemented
                  (win.bar as Rectangle).color = "yellow"
                              ^^^^^^^^^
      

      Runtime output for 6.4.1:

      qml: R1: #000000
      qml: R2: #800080
      qrc:/untitled/main.qml:37: TypeError: green is not a function
      qrc:/untitled/main.qml:29: TypeError: black is not a function
      qml: R1: #ff0000
      qml: R2: #0000ff
      

      Stacktrace for 6.5:

      #0  QQmlJSTypeResolver::scopeForLocation (this=0x7ffe0aa7b858, location=...)
          at /home/qt/work/qt/qtdeclarative_build/include/QtQml/6.5.0/QtQml/private/../../../../../../qtdeclarative/src/qml/common/qv4compileddata_p.h:112
      #1  0x0000000000414c07 in ?? ()
      #2  0x00007f51a8cca089 in operator() (bindingOrFunction=..., __closure=<synthetic pointer>) at /home/qt/work/qt/qtdeclarative/src/qmlcompiler/qqmljscompiler.cpp:327
      #3  std::for_each<__gnu_cxx::__normal_iterator<BindingOrFunction*, std::vector<BindingOrFunction> >, qCompileQmlFile(QmlIR::Document&, const QString&, QQmlJSSaveFunction, QQmlJSAotCompiler*
      , QQmlJSCompileError*, bool, QV4::Compiler::CodegenWarningInterface*, const QString*)::<lambda(const BindingOrFunction&)> > (__f=..., __last={m_binding = 0x6b2330, m_function = 0x61},  
          __first={m_binding = 0x628240, m_function = 0x0}) at /opt/rh/gcc-toolset-10/root/usr/include/c++/10/bits/stl_algo.h:3844
      #4  qCompileQmlFile(QmlIR::Document&, QString const&, std::function<bool (QV4::CompiledData::SaveableUnitPointer const&, QMap<int, QQmlJSAotFunction> const&, QString*)>, QQmlJSAotCompiler*,
       QQmlJSCompileError*, bool, QV4::Compiler::CodegenWarningInterface*, QString const*) (irDocument=..., inputFileName=..., saveFunction=..., aotCompiler=<optimized out>,  
          error=<optimized out>, storeSourceLocation=<optimized out>, interface=<optimized out>, fileContents=<optimized out>)
          at /home/qt/work/qt/qtdeclarative/src/qmlcompiler/qqmljscompiler.cpp:351
      #5  0x00007f51a8ccb726 in qCompileQmlFile(QString const&, std::function<bool (QV4::CompiledData::SaveableUnitPointer const&, QMap<int, QQmlJSAotFunction> const&, QString*)>, QQmlJSAotCompil
      er*, QQmlJSCompileError*, bool, QV4::Compiler::CodegenWarningInterface*, QString const*) (inputFileName=..., saveFunction=..., aotCompiler=0x7ffe0aa7b850, error=0x7ffe0aa7b5b0,  
          storeSourceLocation=<optimized out>, interface=0x42e4c0, fileContents=0x0) at /home/qt/work/qt/qtdeclarative/src/qmlcompiler/qqmljscompiler.cpp:186
      #6  0x000000000040d4b3 in ?? ()
      #7  0x00007f51a764a510 in __libc_start_call_main () from /lib64/libc.so.6
      #8  0x00007f51a764a5c9 in __libc_start_main_impl () from /lib64/libc.so.6
      #9  0x000000000040d87e in ?? ()
      

      Attachments

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

        Activity

          People

            ulherman Ulf Hermann
            cajus Cajus Pollmeier
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes