Qml plugins javascript import broken

• Oct 4, 2018 - 07:24

OS: Windows 7, Arch.: x86_64,
MuseScore version (32-bit): 2.3.2, revision: 4592407
Portable Build

Qml allows importing javascript (http://doc.qt.io/qt-5/qtqml-javascript-imports.html) files in the form
import “myFile.js” as Myfile
where js file path can be either an absolute or relative path.

Indeed back in 2012 (https://musescore.org/en/node/17581) it looks that Musescore was able to handle both absolute and relative js imports.

Now something has broken.
If I import as absolute,
import "file:///C:/local/music/MuseScorePortable/Data/plugins/scoreFuncs.js" as Sf
the plugin runs either from the “Plugin Creator” and from the “Plugins” menu.

If I import as relative import "file:./Data/plugins/scoreFuncs.js" as Sf, (Qt.resolvedUrl("./") shows the current directory is C:/local/music/MuseScorePortable), the plugin runs correctly from “Plugin Creator”, but when I try to enable it from “Plugin Manager” its details, version and descriptions do not show in the right panel and the plugin is not shown in the “Plugins” menu.
This is a regression respect to what shown in 2012 post.

Another question, I’m not a Qt programmer so may be there is an obvious reason, but I didn’t understand it. Why do I have to use the file: syntax for the import to work?
I found this https://stackoverflow.com/questions/45484222/qml-import-external-javasc… , I simply tried it, and it works, but I really didn’t understand what those posts are talking about.
Beside back in 2012, as shown in the cited post, it looks there was no need to use file: syntax for the imports to work.


Comments

Back in 2012 the plugin framework was using .js (MuseScore 1.x) and not .qml (MuseScore 2.x), so it was very a different. Still importing .js should work as far as I'm aware.

In reply to by Jojo-Schmitz

Sorry i didn't realize that back in 2012 there was still the old plugin system.
Do you mean this can be accepted as a bug? What should i do?

BTW, i forget to say that also setting the import path with QML2_IMPORT_PATH env var is ignored.
I didn't find any method to import other than setting full the path into import statement.

In reply to by garu57

Not sure how to proceed, reporting a bug against MuseScore 2.x won't help much, if the same bug doesn't exist in master (which will become 3.0) too, but unfortunatly in master the plugin infrastructure is currently pretty much broken, so you probably won't be able to reproduce the issu there because you'd stumble acrossmuch more fundamental issues first.
Also I'm not sure whether this is a plain Qt issue, or something MuseScore can do anything about.

In reply to by Jojo-Schmitz

As far i understand it should be a Musescore problem, Qt QML is designed to allow what I'm trying to do, unless the application constrains it somehow.

As for 3.0, i tried the alpha release, but I'm just beginning to explore Musescore and, as you say, 3.0 is still too much unstable for me to understand if there's something not working correctly or I'm just doing something odd.

Just in case, can this be opened as a feature request for 3.0? Can you suggest how?
Thanks for your time.

Do you still have an unanswered question? Please log in first to post your question.