diff --git a/vstgui/uidescription-scripting/detail/drawcontextobject.cpp b/vstgui/uidescription-scripting/detail/drawcontextobject.cpp index 68aa31942..8c720dc6b 100644 --- a/vstgui/uidescription-scripting/detail/drawcontextobject.cpp +++ b/vstgui/uidescription-scripting/detail/drawcontextobject.cpp @@ -168,8 +168,8 @@ struct TransformMatrixScriptObject : ScriptObject using TransformMatrixPtr = std::shared_ptr; TransformMatrixScriptObject (TransformMatrixPtr tm = std::make_shared ()) + : ScriptObject (new CScriptVar ("", SCRIPTVAR_OBJECT)) { - scriptVar = new CScriptVar ("", SCRIPTVAR_OBJECT); scriptVar->addRef (); scriptVar->setCustomData (tm); addFunc ("concat"sv, [tm] (auto var) { concat (tm, var); }, {"transformMatrix"sv}); @@ -291,8 +291,8 @@ TJS::CScriptVar* makeTransformMatrixObject () struct GradientScriptObject : ScriptObject { GradientScriptObject (const SharedPointer& g, const IUIDescription* uiDesc) + : ScriptObject (new CScriptVar ("", SCRIPTVAR_OBJECT)) { - scriptVar = new CScriptVar ("", SCRIPTVAR_OBJECT); scriptVar->addRef (); scriptVar->setCustomData (g); @@ -314,8 +314,8 @@ struct GradientScriptObject : ScriptObject struct GraphicsPathScriptObject : ScriptObject { GraphicsPathScriptObject (const SharedPointer& p) + : ScriptObject (new CScriptVar ("", SCRIPTVAR_OBJECT)) { - scriptVar = new CScriptVar ("", SCRIPTVAR_OBJECT); scriptVar->addRef (); scriptVar->setCustomData (p); diff --git a/vstgui/uidescription-scripting/tiny-js/TinyJS.cpp b/vstgui/uidescription-scripting/tiny-js/TinyJS.cpp index 7e14f9072..80209b33f 100644 --- a/vstgui/uidescription-scripting/tiny-js/TinyJS.cpp +++ b/vstgui/uidescription-scripting/tiny-js/TinyJS.cpp @@ -884,7 +884,11 @@ void CScriptVarLink::replaceWith (CScriptVarLink* newVar) if (newVar) replaceWith (newVar->var); else - replaceWith (new CScriptVar ()); + { + auto v = new CScriptVar (); + replaceWith (v); + v->release (); + } } int CScriptVarLink::getIntName () const { return atoi (name.c_str ()); } diff --git a/vstgui/uidescription-scripting/uiscripting.cpp b/vstgui/uidescription-scripting/uiscripting.cpp index 6199b448b..e8abb62b3 100644 --- a/vstgui/uidescription-scripting/uiscripting.cpp +++ b/vstgui/uidescription-scripting/uiscripting.cpp @@ -202,7 +202,9 @@ struct ScriptContext::Impl : ViewListenerAdapter, [this] (CScriptVar* var) { log (var->getParameter ("obj"sv)); }); jsContext->addNative ("function makeTransformMatrix()", [] (CScriptVar* var) { - var->setReturnVar (makeTransformMatrixObject ()); + auto tm = makeTransformMatrixObject (); + var->setReturnVar (tm); + tm->release (); }); }