Plugins are not run correctly when running musescore in converter mode.

• Jan 10, 2020 - 17:21
Reported version
3.x-dev
Priority
P2 - Medium
Type
Plugins
Frequency
Once
Severity
S2 - Critical
Reproducibility
Always
Status
closed
Regression
Yes
Workaround
No
Project

Running musescore with both plugins (-p) and conversion (-o) at the command line will ignore the plugin listed, and convert without running plugins.

To reproduce this issue, simply launch musescore with a plugin such as transpose_0.qml, and a musescore file, i.e.:

mscore -p transpose_0.qml -o Music.pdf Music.mscx

This is due to two small error in musescore.cpp:

  • in the overloaded function convert(QString&, QString&), the conversion routine is called, but without a plugin name. This will cause the plugin name to be ignored at the command line.
  • In the overloaded function convert(QString&, QJsonArray&, QString&), the current loaded score is not appended to the list of scores.

The former error means that no user-specified plugins will be run when in "conversion" mode, the latter means that if they are run, they will encounter errors when they try and modify the current score, as there is no current score available.

These errors are due to a wider issue with brittle command-line behaviour that should be addressed in a future release.

Details on my debugging (along with a small patch that will fix this issue) can be found at this forum node: https://musescore.org/en/node/299531

I plan to open a PR with a cleaned up version of the patch that will fix this issue.


Comments

Status PR created fixed

Fixed in branch master, commit 1cdc669439

_Fix #299539 (Plugins are not run correctly when running musescore in converter mode.)

Resolves: Issue #299539

This PR fixes a set of related logical bugs in the command line interface
handling logic. Essentially, in master as it stands right now, two options
are somewhat intertwined, but break each other in subtle ways, which leads
to plugins being entirely broken when run in command line mode:

  • Plugin mode does nothing when enabled by itself, and after making changes
    to a score, simply discards them.
  • Converter mode (which should then save changes), instead re-loads score
    files, discarding changes made by the plugin mode.
  • Finally converter mode also attempts to run plugins but, however, it
    doesn't run the plugin specified by the user - said plugin name is
    replaced with the empty string, so no plugins are actually run.

The overall effect is that plugins (when specified at the command line)
either a) do something, and then discard their work, or b) are ignored.
This PR fixes this issue in the following way:

  • Converter mode now correctly runs the user-specified plugin when invoked
    with plugin mode.
  • Converter mode also has a small number of fixes to correctly load a score
    in order to allow plugins to run correctly.
  • Standalone plugin mode remains, but only when converter mode is not
    specified._
Fix version
3.5.0