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

QML/Javascript: Using an anonymous function as a default parameter in a function signature crashes the application.

    XMLWordPrintable

    Details

    • Platform/s:
      Linux/X11
    • Commits:
      be194d965d530e57ed5851781c6805e691c6ae98 (qt/qtdeclarative/dev) 28d426a9858b9f757b3eab89688ac38f029fc757 (qt/qtdeclarative/6.2) be32898873237dfd6864112e5242a30f3e680413 (qt/tqtc-qtdeclarative/5.15)

      Description

      Using an anonymous function as a default parameter in a function signature crashes the application:

      // this will crash program
      function crashFunction(functionptr=function(){}){ }
      
      // complete example with work arounds
      import QtQuick 2.15
      import QtQuick.Window 2.15
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Crash QML Default Function Parameter")
      
          // this crashes
          function crashFunction(functionptr=function(){}){ functionptr(); }
      
          // work around 1
          function emptyfunc(){}
          function nocrashFunction(functionptr=emptyfunc){ functionptr(); }
      
          // work around 2
          function nocrashFunction(functionptr=null){
              if(functionptr){
                  functionptr();
              }
          }
      
          // work around 3
          property var crashFunction: function(functionptr=function(){}){ functionptr(); }
      }
      

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              fabiankosmale Fabian Kosmale
              Reporter:
              fcarney Frank Carney
              PM Owner:
              Vladimir Minenko Vladimir Minenko
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes