Skip to content

Commit

Permalink
Plugin: WIP: Revert prior commit to only affect curScore object.
Browse files Browse the repository at this point in the history
This restricts changes of wrapper ownership to CppOwnership for objects
returned by the `curScore` scripting property.
  • Loading branch information
DLLarson committed Sep 11, 2019
1 parent 9b231f5 commit 61a3e78
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
4 changes: 3 additions & 1 deletion mscore/plugin/api/qmlpluginapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ PluginAPI::PluginAPI(QQuickItem* parent)

Score* PluginAPI::curScore() const
{
return wrap<Score>(msc()->currentScore(), Ownership::SCORE);
Score* pscore = wrap<Score>(msc()->currentScore(), Ownership::SCORE);
QQmlEngine::setObjectOwnership(pscore, QQmlEngine::CppOwnership);
return pscore;
}

//---------------------------------------------------------
Expand Down
10 changes: 2 additions & 8 deletions mscore/plugin/api/scoreelement.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,8 @@ Wrapper* wrap(T* t, Ownership own = Ownership::SCORE)
{
w = new Wrapper(t, own);
t->setPlugInWrapper(w);
//@@@@@@ // All wrapper objects should belong to JavaScript code.
//@@@@@@ QQmlEngine::setObjectOwnership(w, QQmlEngine::JavaScriptOwnership);

// All ScoreElement based wrapper objects should belong to Cpp code.
// When the associated MuseScore object is destroyed it will call
// slot "symbiantDestroyed". That handler will set object ownership back to
// the Javascript Engine.
QQmlEngine::setObjectOwnership(w, QQmlEngine::CppOwnership);
// All wrapper objects should belong to JavaScript code.
QQmlEngine::setObjectOwnership(w, QQmlEngine::JavaScriptOwnership);
}
else
w = static_cast<Wrapper*>(t->getPlugInWrapper());
Expand Down

0 comments on commit 61a3e78

Please sign in to comment.