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

Function from js-file becomes global for all files.

XMLWordPrintable

    • Linux/Other display system

      Let's say there are 2 js files:

      Bar.js:

      function say() {
          console.log("BAR")
      }
      

      Foo.js: 

      function say() {
          console.log("FOO")
      }
      this.say = say;
      

      and the main.qml:

      ...
      import "Foo.js" as Foo
      import "Bar.js" as Bar
      
      ...
      
      Component.onCompleted: {
          Foo.say();
          Bar.say(); // !
          say();     // !!!
      }

       

      The output is wrong:

      qml: FOO
      qml: FOO
      qml: FOO
      

       

       

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

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            roumed Roman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes