From fdce049fb92a492df5a271ce310cabc3851f0e7e Mon Sep 17 00:00:00 2001 From: scheffle Date: Wed, 21 Feb 2024 09:01:56 +0100 Subject: [PATCH] fix possible crash --- .../uidescription-scripting/detail/drawcontextobject.cpp | 7 +++++++ vstgui/uidescription-scripting/detail/drawcontextobject.h | 1 + 2 files changed, 8 insertions(+) diff --git a/vstgui/uidescription-scripting/detail/drawcontextobject.cpp b/vstgui/uidescription-scripting/detail/drawcontextobject.cpp index 1c3a51b82..9fdcc2344 100644 --- a/vstgui/uidescription-scripting/detail/drawcontextobject.cpp +++ b/vstgui/uidescription-scripting/detail/drawcontextobject.cpp @@ -272,6 +272,13 @@ DrawContextObject::DrawContextObject () #endif } +//------------------------------------------------------------------------ +DrawContextObject::~DrawContextObject () noexcept +{ + if (scriptVar) + scriptVar->setLifeTimeObserver (nullptr); +} + //------------------------------------------------------------------------ void DrawContextObject::setDrawContext (CDrawContext* inContext, IUIDescription* inUIDesc) { diff --git a/vstgui/uidescription-scripting/detail/drawcontextobject.h b/vstgui/uidescription-scripting/detail/drawcontextobject.h index c98d7e5c4..718f81562 100644 --- a/vstgui/uidescription-scripting/detail/drawcontextobject.h +++ b/vstgui/uidescription-scripting/detail/drawcontextobject.h @@ -17,6 +17,7 @@ struct DrawContextObject : ScriptObject, TJS::IScriptVarLifeTimeObserver { DrawContextObject (); + ~DrawContextObject () noexcept override; void setDrawContext (CDrawContext* context, IUIDescription* uiDesc);