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

Fix #291708 Plugin: Expose NoteEvent's via QML Note interface. #5224

Merged
merged 1 commit into from
Jul 29, 2019

Conversation

DLLarson
Copy link
Contributor

@DLLarson DLLarson commented Jul 15, 2019

Adds capablity to examine and modify PlayEvent's.
PlayEvent's are wrappers for an internal object called a NoteEvent.
The name PlayEvent better reflects what it's role is and what
you are really affecting from the QML plugin. Any changes made
with this feature also creates undo frames so they can be removed from
the user interface.

@DLLarson
Copy link
Contributor Author

'nix build died on:
In file included from /home/travis/build/musescore/MuseScore/mscore/plugin/api/elements.h:28:0,
from /home/travis/build/musescore/MuseScore/mscore/plugin/api/qmlpluginapi.cpp:15:
/home/travis/build/musescore/MuseScore/mscore/plugin/api/noteevent.h: In constructor ‘Ms::PluginAPI::NoteEvent::NoteEvent(Ms::NoteEvent*, QObject*)’:
/home/travis/build/musescore/MuseScore/mscore/plugin/api/noteevent.h:47:20: warning: ‘Ms::PluginAPI::NoteEvent::ne’ will be initialized after [-Wreorder]
Ms::NoteEvent* ne;

But it works fine on Windows builds. Any ideas way?

-Dale

@DLLarson DLLarson force-pushed the qml-expose-noteevents branch 2 times, most recently from 4180c84 to ce17411 Compare July 15, 2019 04:19
@Jojo-Schmitz
Copy link
Contributor

@DLLarson
Copy link
Contributor Author

I see the error but how do I correct?

This code is building and running fine in Windows using vs2017 plus Qt 5.12.2.

What system is the failed build targeting?

-Dale

@DLLarson DLLarson force-pushed the qml-expose-noteevents branch 2 times, most recently from 393d899 to 174368d Compare July 15, 2019 17:44
@dmitrio95
Copy link
Contributor

I see the error but how do I correct?

It looks like tests do not build, you probably need to add the new files to CMakeLists.txt used in mtest:

${PROJECT_SOURCE_DIR}/mscore/plugin/api/util.cpp

@DLLarson
Copy link
Contributor Author

Thanks for the tip!
It now finishes without issue.
-Dale

@DLLarson DLLarson force-pushed the qml-expose-noteevents branch 2 times, most recently from 6b106dc to dcc19fd Compare July 18, 2019 16:41
@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Jul 18, 2019

It doesn't build on Travis CI, looks like you forgot some #include? Probably note.h?

@DLLarson
Copy link
Contributor Author

DLLarson commented Jul 18, 2019

Of course it builds fine in VS2017!

This is one of those compiler difference things that drive me nuts.

The template is declared but not instantiated at the point of failure but only uses pointers yet VS2017 is happy and Linux/gcc is not? Ugggg!

playevent.h needs a definition from elements.h but elements.h also needs playevent.h. Normally just forward defining the empty class and just using pointers is enough.
Templates seem to have other rules.

I'm at a loss. I guess I need to replicate the linux build somehow to investigate this.

-Dale

@DLLarson DLLarson force-pushed the qml-expose-noteevents branch 2 times, most recently from fd5b5bc to bc253ae Compare July 18, 2019 19:05
@mattmcclinch
Copy link
Contributor

I can get this to build by making these changes: mattmcclinch@5cc9957. My solution was to add a function that takes an Ms::PluginAPI::Note* as a parameter, and returns an Ms::Note*, since class QmlPlayEventsListAccess cannot access Ms::PluginApi::Note::note() directly.

@DLLarson
Copy link
Contributor Author

Matt,

Thanks for that!

I'll be looking at it right away!

Meanwhile, I'll share my discovery...

I put together a VMware system with Ubuntu 18.04 all the setup as specified on the MuseScore developer handbook.

I cloned the code, built and I got the same errors... BUT WAIT A MINUTE... those aren't errors. They are warnings. I took the next step to 'make install' and it's running flawlessly on my Ubuntu VM. I loaded the same test score and test plugin I've been using on Windows and it works perfectly.

That makes me feel much better. I'm definitely going to check out Matt's mods to see if it removes the whole situation. Fingers crossed.

The errors posted on Travis-ci may be due to toolchain version. The failed Travis build used:

Ubuntu 14.04--not even described on the developers site as a valid target build system might add.
g++ = 4.8.4.

Yet my system is:

Ubuntu 18.04
g++ 7.4.0 - a BIG difference in toolchains!

With the newer toolchains the error appears to be acceptable as a warning.

Ohhhhh the wonderful world of tools! :)

-Dale

@DLLarson
Copy link
Contributor Author

Excellent! All is right with the build.

Thanks Matt for the skilled eyes on the code!

-Dale

@mattmcclinch
Copy link
Contributor

I am honored that you accepted my changes verbatim, but honestly, I wasn't completely happy with them. Basically, I wanted something a little more general. This is what I have now, which I like a lot better: mattmcclinch@a9efab9.

@DLLarson
Copy link
Contributor Author

am honored that you accepted my changes verbatim, but honestly, I wasn't completely happy with them.

I was happy to stop beating my head against a wall plus it worked!

I'll check out the improved version. Right now I'm spinning in circles trying to expose the PlayEventType enum through a Chord property. When things don't work it can be real confusion.

@mattmcclinch
Copy link
Contributor

Right now I'm spinning in circles trying to expose the PlayEventType enum through a Chord property.

Does this not work? mattmcclinch@29a2883

@DLLarson
Copy link
Contributor Author

DLLarson commented Jul 19, 2019

I got it all working.

I did have what you suggested but it still denied my playEventType r/w property existence when I tried.

THEN I fixed this improper definition that the compiler and tools didn't complain about:

  DECLARE_API_ENUM( Accidental,       accidentalTypeEnum      )

That "Accidental" should be "AccidentalType". This also explained why the AccidentalType enum wasn't available in QML.

 DECLARE_API_ENUM( AccidentalType,       accidentalTypeEnum      )

Anyway, I'm running a local build with your latest tweak so I'm close to sending up the changes.

Oh, also with the new changes I can reset the user playevent and get back the automatic ornamentations. i.e., I can recover that score I hosed!

-Dale

@DLLarson DLLarson force-pushed the qml-expose-noteevents branch 2 times, most recently from bb79ae2 to d15e70e Compare July 20, 2019 03:14
@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Jul 21, 2019

Why then still the WIP label in PR and commit title?

@mattmcclinch
Copy link
Contributor

Don't miss this comment, which isn't showing up because the conversation has been marked as resolved. The part about the forward declaration of class Note is especially important, since although it does not affect whether or not the build succeeds, I'm sure that it does affect whether or not certain objects get cast to the right type.

@DLLarson
Copy link
Contributor Author

DLLarson commented Jul 21, 2019

The part about the forward declaration of class Note is especially important, since although it does not affect whether or not the build succeeds, I'm sure that it does affect whether or not certain objects get cast to the right type.

To be clear, when using reinterpret_cast<>() you are telling the compiler that you know better than it about the cast (it's the nuclear option of casts.) So we better be right--which we are here.

@DLLarson DLLarson changed the title Fix# 291708 [WIP] Plugin: Expose NoteEvent's via QML Note interface. Fix# 291708 Plugin: Expose NoteEvent's via QML Note interface. Jul 21, 2019
@DLLarson
Copy link
Contributor Author

Why then still the WIP label in PR and commit title?

Fixed.

@DLLarson DLLarson force-pushed the qml-expose-noteevents branch 2 times, most recently from 693d08e to 5fcb2af Compare July 23, 2019 22:07
libmscore/types.h Outdated Show resolved Hide resolved
mscore/plugin/api/elements.h Outdated Show resolved Hide resolved
mscore/plugin/api/qmlpluginapi.h Outdated Show resolved Hide resolved
libmscore/undo.cpp Show resolved Hide resolved
mscore/plugin/api/cursor.cpp Outdated Show resolved Hide resolved
@DLLarson DLLarson force-pushed the qml-expose-noteevents branch 2 times, most recently from a29858c to 459804a Compare July 24, 2019 15:25
@@ -0,0 +1,55 @@
import QtQuick 2.0
Copy link
Contributor

@Jojo-Schmitz Jojo-Schmitz Jul 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this and other testing files don't seem to belong into this PR, but at least and for sure not into the top level directory

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was stated in the commit. It will be removed as well as the other commits.
-Dale

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, reading helps ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was the only way I could get an application shared to test good and bad at once. :)

Copy link
Contributor

@dmitrio95 dmitrio95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also while we are at it, could you please add fix #291708 to the commit message? Something like
fix #291708: Expose PlayEvent's via QML Plugin Note interface

libmscore/rendermidi.cpp Outdated Show resolved Hide resolved
libmscore/rendermidi.cpp Outdated Show resolved Hide resolved
libmscore/rendermidi.cpp Outdated Show resolved Hide resolved
void Chord::setPlayEventType(Ms::PlayEventType v)
{
chord()->score()->setPlaylistDirty();
chord()->score()->undo(new ChangeChordPlayEventType(chord(), v));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function could potentially check whether the chord already has a correct play event type, then it could avoid pushing extra unnecessary commands to undo stack. That is not strictly necessary but could optimize this operation a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But isn't it possible that, even though the playEventType hasn't changed, the playEventLists may have? Woudn't those changes would be lost to a missing redo operation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, maybe I didn't understand the question properly. This function has nothing to do with changing note events at all, if a plugin needs to change play events it would modify the Note.playEvents property which would also change the play event type to User.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I understand. Check is added.

-Dale

mscore/plugin/api/playevent.h Show resolved Hide resolved
mscore/plugin/api/playevent.h Show resolved Hide resolved
@dmitrio95 dmitrio95 changed the title Fix# 291708 Plugin: Expose NoteEvent's via QML Note interface. Fix #291708 Plugin: Expose NoteEvent's via QML Note interface. Jul 26, 2019
@DLLarson DLLarson force-pushed the qml-expose-noteevents branch 2 times, most recently from 6334905 to f731b10 Compare July 27, 2019 14:47
@dmitrio95
Copy link
Contributor

It looks like merging #5243 caused some merge conflicts to appear so rebase is needed for this PR. The conflicts seem to be trivial though.

Adds capablity to examine and modify PlayEvent's and a Note's
playEvents list. Adds access to Chord.playEventType. Also
supports UNDO for these operations.
@DLLarson
Copy link
Contributor Author

I was expecting the rebase on this one. Just pushed up the corrections.
-Dale

@dmitrio95
Copy link
Contributor

I tested this patch a bit, looks really impressive! I see now why BSG is so encouraged with these new possibilities :)

I don't catch any issues anymore so I'll merge this PR when all tests get passed.

@DLLarson
Copy link
Contributor Author

I tested this patch a bit, looks really impressive! I see now why BSG is so encouraged with these new possibilities :)

He does seem dang near giddy with the prospects.

His triller.qml plugin posted on the associated issue is really pretty cool! It makes use of the ability to create PlayEvent lists in Javascript to embellish the notes.

This is automation as it should be!

The gui selection stuff was needed to make it easy so that adder was really necessary.

-Dale

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

4 participants