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 #293837: Plugin: WIP: Add ability to compare sameness of MuseScore QML elements. #5281

Closed

Conversation

DLLarson
Copy link
Contributor

@DLLarson DLLarson commented Aug 27, 2019

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

@DLLarson DLLarson force-pushed the plugin-object-comparison-fix branch from 6f14bc6 to 91f3114 Compare August 27, 2019 19:17
@DLLarson DLLarson changed the title Fix #293837: Plugin: Add ability to compare sameness of MuseScore QML elements. Fix #293837: Plugin: WIP: Add ability to compare sameness of MuseScore QML elements. Aug 27, 2019
@DLLarson DLLarson force-pushed the plugin-object-comparison-fix branch 6 times, most recently from 0c9dc58 to 5898b90 Compare August 29, 2019 17:20
@@ -171,6 +171,9 @@ struct ElementName {

class ScoreElement {
Score* _score;
#ifdef SCRIPT_INTERFACE
QObject* _plugInWrapper;
Copy link
Contributor

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.

Copy link
Contributor Author

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

@DLLarson DLLarson force-pushed the plugin-object-comparison-fix branch 4 times, most recently from 46cd6fd to e3b4355 Compare August 31, 2019 03:40
@DLLarson DLLarson force-pushed the plugin-object-comparison-fix branch 2 times, most recently from 1206db1 to 61a3e78 Compare September 11, 2019 18:54
@Jojo-Schmitz
Copy link
Contributor

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.
@vpereverzev vpereverzev added the archived PRs that have gone stale but could potentially be revived in the future label Dec 30, 2020
@vpereverzev
Copy link
Member

Automatically archived due to long inactivity. Could be re-opened later once an author will come back

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
archived PRs that have gone stale but could potentially be revived in the future
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants