musescore / MuseScore

MuseScore is an open source and free music notation software. For support, contribution, bug reports, visit MuseScore.org. Fork and make pull requests!
https://musescore.org
Other
12.18k stars 2.64k forks source link

[MU4 Issue] Courtesy accidental plugins do not work #12867

Closed MarcSabatella closed 2 years ago

MarcSabatella commented 2 years ago

Describe the bug I can enable and run the courtesy accidental plugins, but none of them do anything

To Reproduce Steps to reproduce the behavior:

  1. Enable Add courtesy accidentals plugin
  2. Create score in C major, 4/4
  3. Add quarter notes C C C Bb | B (so the B is in the second measure
  4. Select all
  5. Run Add courtesy accidentals

Result Nothing happens

Expected behavior The B should receive a courtesy natural

Screenshots image

Platform information

Additional context The other courtesy accidentals plugins (remove, configure) do not seem to work either. But other plugins do.

MarcSabatella commented 2 years ago

Actually, "Color notes" works, but neither "new retrograde" nor "mirror intervals" do.

Jojo-Schmitz commented 2 years ago

@heuchi is the original author (of these Courtesy accidental plugins) and might be interested in this

heuchi commented 2 years ago

It's new-major-version time again ;-) I hope the plugin frame work hasn't changed too much. I don't really have time to look into this now and I haven't even looked at version 4, either. So it might take a while... But anyway, thanks for the notification.

heuchi commented 2 years ago

I tried to look at this, but I ran into some difficulties. I don't know if this is the best place to share it, but since they seem to be of different origins but all affect plugin development, I'd list them here. Feel free to suggest a different place. :-)

I'm using the latest nightly build AppImage for Linux ("MuseScoreNightly-latest-x86_64.AppImage" from Aug 28)

  1. Custom qml files (in private "Plugins" folder) are only found if they are not symbolic links. (minor but impractical)
  2. There seems to be no easy way to reload a plugin (other than restarting MuseScore). The "Reload" button in the plugin manager doesn't seem to do anything. (again minor, but impractical)
  3. console.log("some debug message") calls don't appear on the terminal window where I started the AppImage, and I wasn't able to find them anywhere else either. Where do they go? (major problem for debugging)

On a side note: "Color notes" works but cannot be undone.

heuchi commented 2 years ago

I managed to compile MuseScore myself again, which made the console.log() problem go away. The nightly builds don't seem to be debug builds, so they don't show the messages created by plugins.

Now I found that Element.CHORD is undefined in QML. I think the reason is at src/plugins/api/qmlpluginapi.cpp:

Enum* PluginAPI::elementTypeEnum = nullptr;
Enum* PluginAPI::accidentalTypeEnum = nullptr;

At least these two are needed for the courtesy accidental plugins to work. I'm afraid I don't know how to solve this.

HemantAntony commented 2 years ago

Maybe try asking in discord (#development)? People ask dev questions there

Jojo-Schmitz commented 2 years ago

On a side note: "Color notes" works but cannot be undone.

That should indicate that cmdStart and cmdEnd are either not used or not working?

heuchi commented 2 years ago

On a side note: "Color notes" works but cannot be undone.

That should indicate that startCmd and endCmd are either not used or not working?

That one was easier to solve: startCmd() and endCmd() are used only if there's no selection:

function applyToNotesInSelection(func) {
            var fullScore = !curScore.selection.elements.length
            if (fullScore) {
                  cmd("select-all")
                  curScore.startCmd()
            }
            for (var i in curScore.selection.elements)
                  if (curScore.selection.elements[i].pitch)
                        func(curScore.selection.elements[i])
            if (fullScore) {
                  curScore.endCmd()
                  cmd("escape")
            }
      }

Moving these calls out of the if-block should do it. This looks like a more generic function. So there might be other plugins affected.

heuchi commented 2 years ago

Maybe try asking in discord (#development)? People ask dev questions there

Thanks. Yes, I know the discord channels. I was hesitating to ask there, because then I'd have to closely watch the channel, since answers can easily get buried in the stream of messages... I was wondering if there maybe already is an open issue or forum thread about (potentially) missing features of the plugin API and/or the plans for the plugin API? For example, I remember reading somewhere, that the plugin editor won't be included in the initial release of v4.

Jojo-Schmitz commented 2 years ago

Moving these calls out of the if-block should do it. This looks like a more generic function. So there might be other plugins affected.

See PR ~#12245~ #13063 It seems MuseScore 3 does not need this change (but it doesn't harm there either) I've checked the other plugins, they seem to not need this

HemantAntony commented 2 years ago

@Jojo-Schmitz Are you sure you linked the right PR?

Jojo-Schmitz commented 2 years ago

Yes, I' sure to have linked to the wrong one ;-) I meant #13063

heuchi commented 2 years ago

Please see #13585 for an in-depth analysis of the problem by @cbjeukendrup.

Tantacrul commented 2 years ago

Actually, "Color notes" works, but neither "new retrograde" nor "mirror intervals" do.

If any specific plugin isn't working, can you log it individually? I think these should be working for release or removed until they do. Cheers!

cbjeukendrup commented 2 years ago

(PR to fix the enum issue coming soon; probably that fixes the whole plugin.)

cbjeukendrup commented 2 years ago

@MarcSabatella @heuchi Please check https://github.com/musescore/MuseScore/pull/13669! :)

MarcSabatella commented 2 years ago

Yay! The courtesy accidental plugins now seem to work. To me that's huge. New retrograde works too, albeit with a weird glitch in which the selection oddly seems messed up after running it.

But, it seems to have broken something about mirror intervals and the tuning plugins. In current builds, they show a dialog, and you can make settings and hit Apply, which closes the dialog but doesn't otherwise do anything. In the artifact from this PR, hitting Apply doesn't close the dialog. So I have to cancel out, and then it still doesn't do anything.

cbjeukendrup commented 2 years ago

@MarcSabatella Thanks for catching that! I have fixed it in the plugins themselves. Unfortunately, there's a tiny compatibility break here: we can't use Ms for enums anymore, because now all enums are in one namespace, which causes name clashes for some enums. For example, CHORD is both an ElementType and an ANCHOR. So, Ms.CHORD is now ambiguous and doesn't work anymore, and anything from Ms.… causes a lot of warnings. Therefore I decided to retire it. Do you estimate that this affects a lot of user plugins, and/or can we live with it?

MarcSabatella commented 2 years ago

I don't have a good handle on that, @jeetee might. But I would also say, it's almost to be expected that plugins will need some sort of update to work going between major versions. If that's the worst of it, and there is a clear and simple way to update older plugins, I suspect there will be some grumbling but it will gradually die out as the plugins get updated.

jeetee commented 2 years ago

I don't think many plugins used the Ms. version for enums at all. In 3.x I (and most that I'm aware of) already used Element.CHORD for comparing with element.type (cfr. the older walk.qml#L85 tech demo plugin)

I can't even recall Ms.<enumValue> ever being used, but that might just as well be my memory playing up 😅

DmitryArefiev commented 2 years ago

Fixed in #13669