Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plug-in can “corrupt” score #22889

Open
TeeDeeY opened this issue May 18, 2024 · 9 comments
Open

Plug-in can “corrupt” score #22889

TeeDeeY opened this issue May 18, 2024 · 9 comments
Labels
P4 Priority: Trivial plugins Related to MuseScore's QML plugin framework (NOT VST/audio plugins) time signatures UX/interaction

Comments

@TeeDeeY
Copy link

TeeDeeY commented May 18, 2024

Issue type

UX/Interaction bug (incorrect behaviour)

Bug description

Changing a measure’s time sig actual using a plug-in can lead to a “corrupt score”. I modified the Musescore test1.qml to demo the action. The plug-in and video will be attached.

This was tested in MS 4.4 but has been a problem in prior 4.x versions.

Steps to reproduce

Copy the plug-in into the plug-ins directory, manage plug ins, add it. It’s a modified MS 4.4 demo plugin, with the title changed to include “time signature”.

Open a brand new score, any instrument, with default 4/4 signature. Run plug-in. Notice the + sign on the measure. It is 5/4, but only allows 4 notes to be entered. Saving the file in the current state gives a corruption warning. Going to the measure and pressing the DEL key “fixes” it, and then the measure can accept five quarter notes, and be saved correctly.

Screenshots/Screen recordings

No response

MuseScore Version

4.4

Regression

No.

Operating system

Ubuntu 24.04

Additional context

No response

@TeeDeeY
Copy link
Author

TeeDeeY commented May 18, 2024

Screencast.from.2024-05-18.01-43-01.webm

@TeeDeeY
Copy link
Author

TeeDeeY commented May 18, 2024

test1-ts.zip

@TeeDeeY
Copy link
Author

TeeDeeY commented May 18, 2024

When the measure's "actual" time signature is changed using a plug-in, it should be ready for correct input, like when using the GUI. In this case, it is not. Having to press the DEL key in the GUI to cure the corruption problem is not helpful for plugins, but does demonstrate the situation.

Please look at the plugin. It is very minimal but should demonstrate the point. It changes the first measure's Actual Time Signature to 5/4, so the score should originally start with a 4/4 time signature, so a change happens.

Thanks for checking on this.

@jeetee
Copy link
Contributor

jeetee commented May 18, 2024

This was/is an issue in MS3 as well; where I couldn't get it to work out even with interaction tricks such as swapping voices twice etc.

It's why the TimeSig Enforcer plugin uses insert and delete commands rather than actual time signature duration manipulation. (See https://musescore.org/en/project/time-signature-enforcer for that one, not (yet?) ported to MS4)

@TeeDeeY
Copy link
Author

TeeDeeY commented May 18, 2024

My time signature copy/paste plugin copies the range of time signatures correctly but when changing a measure’s actual time signature (different than the nominal) to match the original, the measure is corrupted. I’ve tried workarounds but couldn’t get them to work.

A measure’s “actual” time signature copy was requested by a user who actually needs the function.

@MarcSabatella
Copy link
Contributor

MarcSabatella commented May 18, 2024

In theory, after changing the duration you would fill any gaps that result with one of the functions dedicated to that purpose. That's what would happen internally after changing a duration etc. But probably those functions aren't exposed to plugins, so you'd have to do it by doing the math and inserting appropriate rests yourself.

In the future, it would be nice indeed if the plugin API were defined in such a way that a user plugin would be incapable of corrupting a score - if changing a measure durations worked more like the measure properties dialog and did the rest fill automatically.

@TeeDeeY
Copy link
Author

TeeDeeY commented May 18, 2024

In theory, after changing the duration you would fill any gaps that result with one of the functions dedicated to that purpose. That's what would happen internally after changing a duration etc. But probably those functions aren't exposed to plugins, so you'd have to do it by doing the math and inserting appropriate rests yourself.

In the future, it would be nice indeed if the plugin API were defined in such a way that a user plugin would be incapable of corrupting a score - if changing a measure durations worked more like the measure properties dialog and did the rest fill automatically.

After the plug-in is run, the measure only allowed 4 notes to be entered, as shown in the video. I’ve tried adding notes to cause a “reset” but that didn’t work, so it’s not a “math” issue. Using DEL in the GUI fixes it, showing that the plug-in interface needs to take some “known” additional steps to accomplish the task.

Hopefully fixing the issue for plugins helps in other situations. Sometimes scores are corrupted and fixing it in one place may help prevent problems in other areas of the program that use the same function calls.

@MarcSabatella
Copy link
Contributor

Yes, I get that four beats only were present, because as I said, normally would need to have the plugin then fill in the gap it just created. Except the function to do that probably my isn’t available in the API.

The math I mean is calculating how many additional beats you need and lengthening the last note to cover that duration, etc. presumably it’s possible but would just take work. Best to ask for help with things like that in the plugins forum at MuseScore.org

meanwhile, as a feature request, yes it would be good if changing measure duration did that for you so you don’t have to add that code yourself.

@TeeDeeY
Copy link
Author

TeeDeeY commented May 18, 2024

If the Plug-in API performed the same tasks as the “right-click, measure properties, change the ‘actual’ time signature numbers, save”, things would be OK as well. The process is already worked out. Hopefully this get scheduled for fixing.

@cbjeukendrup cbjeukendrup added the plugins Related to MuseScore's QML plugin framework (NOT VST/audio plugins) label May 19, 2024
@bkunda bkunda added time signatures P4 Priority: Trivial labels May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P4 Priority: Trivial plugins Related to MuseScore's QML plugin framework (NOT VST/audio plugins) time signatures UX/interaction
Projects
Status: In the further future
Development

No branches or pull requests

6 participants