quickflux
quickflux copied to clipboard
no launch app
hello guys, I'm starting using this extension the flux, but no work in qt 5.12.0. My app and examples don't dispatch any signal.
thanks.
Same here. More specifically, I get this debugger warning upon clicking "Pick Image" in the "Photo Album" example:
Warning: Using function expressions as statements in scripts is not compliant with the ECMAScript specification: "function(dispatcher) { return function() {dispatcher.dispatch(argument..." This will throw a syntax error in Qt 5.12. If you want a function expression, surround it by parentheses. jsruntime\qv4script.cpp: 96
Found the way to fix this. The Qt 5.12 has updated to Ecmascript 7 evaluating the javascript code in qfmiddlewarehook.cpp has a way that new ecma does not understand anymore:
Debugging the issue and I went to look about eval with functions in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval - where it states: var fctStr1 = 'function a() {}' var fctStr2 = '(function a() {})' var fct1 = eval(fctStr1) // return undefined <<< Which is the case in current QuickFlux var fct2 = eval(fctStr2) // return a function
So I added '(' and ')' signs to QFMiddlewaresHook::setup function's QString source string definitions, like: QString source = "(function (middlewares, hook) {" " function create(senderIndex) {" " return function (type, message) {" " hook.next(senderIndex, type , message);" " }" " }" " var data = middlewares.data;" " for (var i = 0 ; i < data.length; i++) {" " var m = data[i];" " m._nextCallback = create(i);" " }" "})";
and source = "(function (middlewares, hook) {" " return function invoke(receiverIndex, type , message) {" " if (receiverIndex >= middlewares.data.length) {" " hook.resolve(type, message);" " return;" " }" " var m = middlewares.data[receiverIndex];" " if (m.filterFunctionEnabled && m.hasOwnProperty(type) && typeof m[type] === "function") { " " mtype;" " } else if (m.hasOwnProperty("dispatch") && typeof m.dispatch === "function") {" " m.dispatch(type, message);" " } else {" " invoke(receiverIndex + 1,type, message);" " }" " }" "})";
--> And after this I got all the distpaches working! @benlau Would you like me todo patch or do you have some other changes in pipeline?
@snowgrains @benlau I've applied your patches and tried to run the photoalbum app. It still does not work. Nothing happens after selecting an image file via FileDialog. Any help?
Good finding. Seems I had older version of the quickflux or my own apps did not use the setCondition. I tested now the latest photoalbum example and got same problem. Qt compile error gave me a hint:
Warning: Using function expressions as statements in scripts is not compliant with the ECMAScript specification: "function(dispatcher) { return function() {dispatcher.dispatch(argument..." This will throw a syntax error in Qt 5.12. If you want a function expression, surround it by parentheses.
Which led me to way to find if there are another evaluate strings that should have parenthesis. So to fix this add parenthesis to file qfappscriptrunnable.cpp function QFAppScriptRunnable::setCondition(QJSValue condition).
Change QString generator to (added just parenthesis): QString generator = "(function(dispatcher) { return function() {dispatcher.dispatch(arguments)}})";
Hello all,
Sorry for late reply. I was too busy for the last few months..
@snowgrains Thx for the information.
I have pushed a fix for this issue and released v1.1.2 on qpm.
Please check. thx