-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 #293837: Plugin: WIP: Add ability to compare sameness of MuseScore QML elements. #5281
Conversation
6f14bc6
to
91f3114
Compare
0c9dc58
to
5898b90
Compare
libmscore/scoreElement.h
Outdated
@@ -171,6 +171,9 @@ struct ElementName { | |||
|
|||
class ScoreElement { | |||
Score* _score; | |||
#ifdef SCRIPT_INTERFACE | |||
QObject* _plugInWrapper; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can define a default value for this variable just here:
QObject* _plugInWrapper = nullptr;
Then there will be no need in having two different constructors depending on SCRIPT_INTERFACE
definition and in initializing this value explicitly in copy constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Much cleaner now.
-Dale
46cd6fd
to
e3b4355
Compare
1206db1
to
61a3e78
Compare
rebase neeeded |
…e QML elements. A property named 'elementId' has been added to all score elements so that QML scripting can compare two different QML elements to see if they are accessing the same MuseScore object beneath the plugin wrappers. This is needed because there may be more than one wrapper for an object at the scripting layer depending how the script obtained the element object.
This patch ensures that there is only one QML wrapper object for each internal object that is exposed to scripting. This enables simple sameness comparisons between javascript objects.
Change Ms::PluginAPI::ScoreElement based wrapper ownership to be "QQmlEngine::CppOwnership" rather than "QQmlEngine::JavaScriptOwnership" so that wrappers won't be garbage collected before the proxied Ms::ScoreElement is destroyed. Upon destruction of the proxied element, the wrapper ownership will be set to "JavaScriptOwnership" and the wrapper's pointer to the wrapped element is set to nullptr to prevent accessing freed heap memory. NOTE: This commit should be merged into the main commit when found to be an acceptable approach.
This restricts changes of wrapper ownership to CppOwnership for objects returned by the `curScore` scripting property.
61a3e78
to
4dd8ad4
Compare
Automatically archived due to long inactivity. Could be re-opened later once an author will come back |
This PR is a work in progress to test ideas for comparing objects in QML scripts.
Note that there may be several patches using different solutions. When the PR is ready to go it will be reduced down to the final approach.
-Dale