plugin API: cannot set show property for a Part in 3.x

• Feb 15, 2020 - 13:51
Reported version
3.3
Type
Plugins
Frequency
Once
Severity
S5 - Suggestion
Reproducibility
Always
Status
closed
Regression
Yes
Workaround
No
Project

Regression from "import MuseScore 1.0"

The show property of a Part is now read only (and documented as such).
Existing code now shows:

currentScore.parts[p].mute = true; // no audio output
currentScore.parts[p].show = false; // no presence of part on sheet

21:-1: TypeError: Cannot assign to read-only property "show"
In mscore/plugin/api/part.h, it is defined as

Q_PROPERTY(bool show READ show)

instead of

Q_PROPERTY(bool show READ show WRITE setShow)

and later only:

bool show() const { return part()->show(); }

and no

void setShow(bool v) const { part()->setShow(v); }

which is however implemented in libmscore/part.cpp as

// @P show bool check/set whether or not a part is shown
(...)
bool show() const { return _show; }
void setShow(bool val) { _show = val; }

Would it be possible to reinstate the write possibility on this property ?
I would need to go back to previous version only to have my plugin working...

Thanks in advance,

Pierre A.


Comments

P.S. Other properties that I am not using have also been treated the same way, so maybe it would be nice to make them all read/write when editing and committing the file...

Frequency Many Once
Severity S1 - Blocker S5 - Suggestion

Import MuseScore 1.0 whould have been MuseScore 1, wouldn't it? But this is rather a regression vs. MuseScore.

Not a bug, just not (yet) implemented, and documented as such, so a feature request, AKA Suggestion (and only requested once so far ;-))

Status active PR created

See https://github.com/musescore/MuseScore/pull/6722

Note that Part.mute property is also unavailable in MuseScore 3 so the code using it will also not work. Since parts can contain multiple instruments, and each instrument can contain multiple channels, an API to manipulate these instruments and channels was added. With this API plugins can mute all or only some of those channels if they need to, see the code sample here (the documentation at musescore.github.io still seems to be not up-to-date).

Fix version
3.6.0