LibCecSharp: delete the internal callback struct when closing the connection
authorLars Op den Kamp <lars@opdenkamp.eu>
Wed, 15 Feb 2012 16:29:36 +0000 (17:29 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Wed, 15 Feb 2012 16:29:36 +0000 (17:29 +0100)
src/LibCecSharp/CecSharpTypes.h
src/LibCecSharp/LibCecSharp.cpp

index 39ef0cb28db367bb2b50f9596130b02b8ddfa7e3..49955743d48f2f4a4475353f34188837c1c01081 100644 (file)
@@ -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;
index 9c1c44ad0a7ca5db1eba0822809eee24a0893265..971dc4d6f7daea3d3370b127ade3a2ec6d8d0f47 100644 (file)
@@ -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();