Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
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()")