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

[Reg 6.5 -> 6.8] Qt 6.8 silently removed sharing of global variables between 2 typescript/javascript files

    XMLWordPrintable

Details

    Description

      In our project, we currently use Qt 6.3.2, which is an application that with help qrc bundle itself into single binary.
      We use C++, but most of our code is in QML and typescript(compiled in cmake to javascript files)

      We wanted to update to latest LTS - 6.8.1

      We use something like that

      main.qml

      import QtQuick
      // import "b1.mjs" as B1 // Uncommenting this line, triggers bug
      
      Window {
          id: mainWindow
          objectName: "mainWindow"
          width: 500
          height: 500
          visible: true
      
          Loader {
              id: contentLoader
              anchors.fill: parent
              source: "loaded.qml"
          }
      }
      

      loaded.qml

      import QtQuick
      import "./a1.mjs" as A1
      import "./b1.mjs" as B1
      
      Item {
          id: root
      
          Component.onCompleted: {
              A1.process_a1()
              B1.read_from_b1()
          }
      }
      

      a1.mjs

      import {read_from_b1} from "./b1.mjs";
      
      export let data_a1: any
      
      export function process_a1() {
          data_a1 = "DATA_IN_A1"
          console.error("In a1 -", data_a1)
          read_from_b1()
      }
      

      b1.mjs

      import {data_a1} from "./a1.mjs";
      
      export function read_from_b1() {
          console.error("In B1", data_a1)
      }
      

      in versions <6.8 (I found that this works fine up to 6.7.3 version) or with line `import "b1.mjs" as B1` commented in main.qml I see

      In a1 - DATA_IN_A1
      In B1 DATA_IN_A1
      In B1 DATA_IN_A1
      

      but in 6.8(both 6.8.0 and 6.8.1) with uncommented line I see

      In a1 - DATA_IN_A1
      In B1 undefined
      In B1 undefined
      
      

      I couldn't find any info in changelog that could point that this behavior is changed, so I assumed that this may be a bug

      Attachments

        For Gerrit Dashboard: QTBUG-133053
        # Subject Branch Project Status CR V

        Activity

          People

            ulherman Ulf Hermann
            rafalmik Wojciech Frey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are 2 open Gerrit changes