fix #306551: make symbols accessible to plugins #6205
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves: https://musescore.org/en/node/306551
Exposes
SymId
enumeration to plugins thus making possible handling symbols in plugins depending on their type. As mentioned in the issue,Symbol
elements can already be accessed (and even be added to a score) by plugins.This PR employs the same technique as #6065 to expose enumeration to plugins while avoiding copying it between files. However
BEGIN_QT_REGISTERED_ENUM
andEND_QT_REGISTERED_ENUM
macro definitions needed to be duplicated instyle.h
andsym.h
asmoc
tool doesn't handle macros from included files (not sure whether it handles#include
statements at all). Also, sinceSymId
enumerators begin from lower case letters, in order to expose their values to QML adding a wrapper for this enumeration was also necessary.Since
SymId
contains a lot of elements (about 2600) creating a wrapper caused a significant delay on MuseScore startup. In order to avoid this in the second commit I implemented lazy initialization of enumerations exposed to QML plugins framework. Now enumeration wrappers are created when they are actually used for the first time. Therefore first access within a session toSymId
enumeration still causes a significant delay, but it doesn't happen after that, and it doesn't cause any issues for anyone not using plugins accessingSymId
enumeration. This trade-off seems to be the best solution we can afford at the moment if exposingSymId
enumeration in the same way as other enumerations.