From: Lars Op den Kamp Date: Wed, 15 Feb 2012 16:29:36 +0000 (+0100) Subject: LibCecSharp: delete the internal callback struct when closing the connection X-Git-Tag: upstream/2.2.0~1^2~35^2~41 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=dae4328cd6aa5289525ada3810135b7beb3fa29a;p=deb_libcec.git LibCecSharp: delete the internal callback struct when closing the connection --- diff --git a/src/LibCecSharp/CecSharpTypes.h b/src/LibCecSharp/CecSharpTypes.h index 39ef0cb..4995574 100644 --- a/src/LibCecSharp/CecSharpTypes.h +++ b/src/LibCecSharp/CecSharpTypes.h @@ -663,8 +663,15 @@ namespace CecSharp } public: + virtual void DisableCallbacks(void) + { + if (m_bHasCallbacks) + delete m_callbacks; + m_bHasCallbacks = false; + } virtual bool EnableCallbacks(CecCallbackMethods ^ callbacks) { + DisableCallbacks(); if (!m_bHasCallbacks) { m_bHasCallbacks = true; diff --git a/src/LibCecSharp/LibCecSharp.cpp b/src/LibCecSharp/LibCecSharp.cpp index 9c1c44a..971dc4d 100644 --- a/src/LibCecSharp/LibCecSharp.cpp +++ b/src/LibCecSharp/LibCecSharp.cpp @@ -148,6 +148,7 @@ namespace CecSharp void Close(void) { // delete the callbacks, since these might already have been destroyed in .NET + CecCallbackMethods::DisableCallbacks(); m_libCec->EnableCallbacks(NULL, NULL); m_libCec->StandbyDevices(); m_libCec->Close();