Do not cache libraries when playing a plugin from the Plugin Creator console

• May 25, 2021 - 17:53
Reported version
3.6
Type
Functional
Frequency
Once
Severity
S5 - Suggestion
Reproducibility
Always
Status
active
Regression
No
Workaround
Yes
Project

Preparation

Within the Plugin creator console, create a plugin with the following code, and save it:

import QtQuick 2.9
import MuseScore 3.0
import "testlib.js" as TestLib // <--  important
MuseScore {
      menuPath: "Plugins.pluginName"
      description: "Description goes here"
      version: "1.0"
      onRun: {
            console.log(TestLib.sharedProp) // <--  important
            Qt.quit()
            }
      }

Create in the same folder a file named testlib.js with the following content:

var sharedProp = "FOO";

In the Plugin creator console, execute the plugin.
On the console's output, the following line is printed:

Debug: FOO

Test

Modify the testlib.js file and save it :

var sharedProp = "BAR";

In the Plugin creator console, execute the plugin.

Expected result

The new version of testlib.js should be used and, on the console's output, the following line should be printed:

Debug: BAR

Actuall result

On the console's output, the following line is printed:

Debug: FOO

Analyse

The libraries are only loaded once. The first time they are needed. While they should be reloaded each time.

Solution

The solution is to have either:

(As I user) I want that every time I run a plugin from the Plugin Creator console, the imported libraries are re-read from their source location automatically instead of being read from cache, in order to take into account the modifications brought to those libraries.

-or-

(As I user) I want to have a toolbar button in the Plugin Creator console that would clean the cache of libraries in order that, at the next run of the plugin in the console, the libraries will be re-read from their source location and the modifications brought to the libraries taken into account.

Workaround

Go to the MS frontend and ask for reloading the plugins - OR - close/reopen MuseScore

Discussion forum

The point has been raised in the Feature Request forum, but they was "little" discussion on that point.
https://musescore.org/en/node/321490


Comments

In reply to by Jojo-Schmitz

many vs. once : I put "many" because it is actually every time and not once from time to time.
It is *every time" you modify an imported library that you to do that painful workaround to have it loaded.