Skip to content

Commit

Permalink
fix memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
scheffle committed Jul 14, 2024
1 parent 43654f5 commit ae37ec1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions vstgui/uidescription-scripting/detail/drawcontextobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ struct TransformMatrixScriptObject : ScriptObject
using TransformMatrixPtr = std::shared_ptr<CGraphicsTransform>;

TransformMatrixScriptObject (TransformMatrixPtr tm = std::make_shared<CGraphicsTransform> ())
: 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});
Expand Down Expand Up @@ -291,8 +291,8 @@ TJS::CScriptVar* makeTransformMatrixObject ()
struct GradientScriptObject : ScriptObject
{
GradientScriptObject (const SharedPointer<CGradient>& g, const IUIDescription* uiDesc)
: ScriptObject (new CScriptVar ("", SCRIPTVAR_OBJECT))
{
scriptVar = new CScriptVar ("", SCRIPTVAR_OBJECT);
scriptVar->addRef ();
scriptVar->setCustomData (g);

Expand All @@ -314,8 +314,8 @@ struct GradientScriptObject : ScriptObject
struct GraphicsPathScriptObject : ScriptObject
{
GraphicsPathScriptObject (const SharedPointer<CGraphicsPath>& p)
: ScriptObject (new CScriptVar ("", SCRIPTVAR_OBJECT))
{
scriptVar = new CScriptVar ("", SCRIPTVAR_OBJECT);
scriptVar->addRef ();
scriptVar->setCustomData (p);

Expand Down
6 changes: 5 additions & 1 deletion vstgui/uidescription-scripting/tiny-js/TinyJS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()); }
Expand Down
4 changes: 3 additions & 1 deletion vstgui/uidescription-scripting/uiscripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
});
}

Expand Down

0 comments on commit ae37ec1

Please sign in to comment.