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

Plugin API: add support for tuplets, add Cursor.addRest() #6085

Merged
merged 2 commits into from
Jun 2, 2020

Conversation

dmitrio95
Copy link
Contributor

Accordingly to what has been discussed in the Telegram chat some time ago, this PR provides an access to Tuplet objects from plugins. In addition to what has been discussed, it also adds a way to enter tuplets with a Cursor. Therefore plugins should be able both to enter tuplets and access properties of already existing tuplets. To complement all this, this PR adds an ability to add rests in a similar way with Cursor (similarly to what has been proposed in #1264 (comment)) which should make Cursor a more feature-complete way to programmatically edit musical content of scores from plugins.

@markshepherd
Copy link

Hi, I am delighted to see this PR, thanks for creating it! I built and ran dmitrio95:plugin-api-rests-tuplets, and I think I found a bug.

  1. create a new empty score
  2. open the Plugin Creator and paste the following code:
    import MuseScore 3.0
    MuseScore {
    pluginType: "dialog"
    onRun: {
    var cursor = curScore.newCursor();
    cursor.track = 0;
    cursor.rewind(Cursor.SCORE_START);
    cursor.addTuplet(fraction(3,2), fraction(1,1));
    }
    }
  3. Run the plugin
  4. Close the empty window that the plugin displayed
  5. in the score, click the tuplet bar (see screenshot)

Result: EXC_BAD_ACCESS (code=1, address=0x28). See screenshots.
The problem does not happen if you remove "pluginType: "dialog"" from the code.

I am running MuseScore from XCode 11.4.1, OS: macOS 10.15, Arch.: x86_64, MuseScore version (64-bit): 3.5.0, revision: github-musescore-musescore-41abc27

Screen Shot 2020-05-20 at 14 12 34

Screen Shot 2020-05-20 at 14 13 55

Screen Shot 2020-05-20 at 14 13 39

@markshepherd
Copy link

Hi I think I found another bug in this PR.

  1. create a new empty score
  2. fill the first measure with quarter notes, and select the 3rd and 4th note. See screenshot.
  3. open the Plugin Creator and paste in this code:
    import MuseScore 3.0
    MuseScore {
    onRun: {
    var cursor = curScore.newCursor();
    cursor.track = 0;
    cursor.rewind(Cursor.SELECTION_START);
    cursor.addTuplet(fraction(3,2), fraction(1,1));
    }
    }
  4. run the plugin

Result: the score looks wrong. See screenshot.

  1. Save the score, close it, and try to open it again.

Result: error message: the score is corrupted.

I am running MuseScore from XCode 11.4.1, OS: macOS 10.15, Arch.: x86_64, MuseScore version (64-bit): 3.5.0, revision: github-musescore-musescore-41abc27

Screen Shot 2020-05-20 at 14 51 13

Screen Shot 2020-05-20 at 14 50 26

Screen Shot 2020-05-20 at 14 49 15

@dmitrio95
Copy link
Contributor Author

Hi @markshepherd, thanks for reporting these issues! I added a check which prevents the second case from happening: MuseScore doesn't support cross-measure tuplets at the moment so plugins shouldn't be able to add such tuplets either.

However I wasn't able to reproduce the first issue with a crash on clicking a tuplet. Does this happen when clicking a tuplet which was not created by this plugin, and does this happen if running an installed version of plugin instead of using a Plugin Creator? I suspect there is something MacOS-specific here, and it is also quite likely to be unrelated to this pull request. But it would be good to know a way to reproduce the issue if it exists.

@markshepherd
Copy link

markshepherd commented May 22, 2020

@dmitrio95 I'm glad you found an easy fix for the 2nd issue.

Regarding the 1st issue: it happens only if i follow exactly the instructions and do nothing else. For example, if after step 3 I close the Plugin Creator, the problem doesn't happen. Or if I switch to another app and then switch back, it doesn't happen. Or if I toggle between windows.

Regarding your questions.. yes, the crash happens if I install the plugin and invoke it from the Plugins menus. And yes, it happens if I click on a tuple that I created manually using cmd-3 in the score.

I made another tiny plugin crash2.qml.zip that does NOT create a tuple, and the crash still happens ...

  1. launch MuseScore
  2. create a new empty score
  3. select a whole rest and use cmd-3 to create a triplet
  4. select menu item Plugins > crash2...
  5. close the plugin's empty dialog
  6. click on the triplet bar

Result: Same crash as before. I tried these steps on MuseScore 3.5, MuseScore 3.5 alpha, MuseScore nightly from May 12, my private debug build of plugin-api-rests-tuplets, and my own release build of plugin-api-rests-tuplets. The crash only occurs on the plugin-api-rests-tuplets builds.

Too bad this is not happening for you, it may well be macos specific. LMK if there is anything else I can do to help track it down.

@dmitrio95
Copy link
Contributor Author

Does the crash occur if you build 3.x or master branch? This pull request's branch doesn't seem to change anything that could cause this crash, it simply adds implementation of more objects and methods exposed to QML plugins.

@markshepherd
Copy link

markshepherd commented May 24, 2020

Hi, I found that the crash occurs when I

  • build and run master branch of your repo in XCode
  • build and run 3.x branch of your repo in XCode
  • build and run 3.x branch of your repo release build from command line
  • build and run master branch of MuseScore repo in XCode
  • build and run 3.x branch of MuseScore repo in XCode

I think this means it's not a bug in your PR, and it's not specific to your repo, and it's not new. Sorry about that. Since the problem only seems to happen on builds that I make, and not in the published builds, I don't know if I should open a musescore issue. What do you think? (FWIW, my dev environment was freshly installed according to the MuseScore docs just a week or two ago, and I have made no changes to anything).

@dmitrio95
Copy link
Contributor Author

I think creating an issue in the tracker would be good anyway. It is certainly not the most important issue for now but it may be related to Qt version or something like that which may become important later.

As I mentioned that, which Qt version do you use in your builds? I tested this only with Qt 5.9.8 which is used by release builds which may also explain why I wasn't able to reproduce the issue.

@markshepherd
Copy link

Sure, I'll open an issue. I have installed QT 5.12.8.

@anatoly-os anatoly-os merged commit a4f47db into musescore:3.x Jun 2, 2020
@dmitrio95 dmitrio95 deleted the plugin-api-rests-tuplets branch June 2, 2020 23:16
anatoly-os added a commit that referenced this pull request Jul 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants