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

Offer alternate names for WorkerScript.sendMessage() and WorkerScript.onMessage()

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P3: Somewhat important
    • 6.0
    • None
    • None

    Description

      //main.qml
      Rectangle {
          WorkerScript {
              id: worker
              source: "myscript.js"
              onMessage: console.debug("Got a message!")
          }
      
          MouseArea {
              anchors.fill: parent
              onClicked: worker.sendMessage()
          }
      }
      

      To a casual reader who's unfamiliar with WorkerScript, the above code strongly suggests that a debug message will be printed as a direct result of a mouse click. In reality,

      • sendMessage() in main.qml is connected to onMessage() in myscript.js, and
      • sendMessage() in myscript.js is connected to onMessage() in main.qml

      That's unintuitive.

      Suggestion

      • Let the QML code start running the .js file using "worker.sendMessage()", but
      • Let the .js file return the result with "WorkerScript.sendReply()", and let the QML signal handler be called "onReply()" (any other names are fine too, just not "sendMessage()" and "onMessage()")

      Attachments

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

        Activity

          People

            aalpert Alan Alpert
            jksh Sze Howe Koh
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes