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

QtQuick compiler treats parameters of a signal handler differently if called arguments

    XMLWordPrintable

Details

    Description

      Consider the following snippet:

      test.qml
      import QtQuick 2.6
      
      Rectangle {
          id: root
      
          color: "red"
          height: 500
          width: 500
      
          signal doit(var arguments)
      
          onDoit: {
              console.warn("json: " + JSON.stringify(arguments));
          }
      
          MouseArea {
              anchors.fill: parent
              onClicked: {
                  doit({item: "test",
                           params: {
                               asdf: "fdsa",
                               x: 4
                           }
                       });
              }
          }
      }
      

      In this code, the "arguments" has different semantics when interpreted than when it is compiled with QtQuick compiler.

      Output when QtQuick compiled (note the "0"):

      Warning (qml): test.qml:13: json: {"0":{"item":"test","params":{"asdf":"fdsa","x":4}}}
      

      Output when interpreted:

      Warning (qml): test.qml:13 (in onDoit): json: {"item":"test","params":{"asdf":"fdsa","x":4}}
      

      Looks like QtQuick Compiler treats "arguments" as the JavaScript Arguments object, whereas interpreter treats it as the parameter name.

      Attachments

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

        Activity

          People

            shausman Simon Hausmann
            alexbusenius Alex Busenius
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes