cec: fixed crash on exit in LibCecSharp
[deb_libcec.git] / src / LibCecSharp / LibCecSharp.cpp
index 3aa1253512034786373e2ad432bfeff429ae623a..06a98aaedda1fa16c96073da03a12a51d1971589 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the libCEC(R) library.
  *
- * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited.  All rights reserved.
+ * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited.  All rights reserved.
  * libCEC(R) is an original work, containing original code.
  *
  * libCEC(R) is a trademark of Pulse-Eight Limited.
@@ -30,7 +30,6 @@
  *     http://www.pulse-eight.net/
  */
 
-#include "stdafx.h"
 #include <windows.h>
 #include <vcclr.h>
 #include <msclr/marshal.h>
@@ -589,7 +588,7 @@ public:
    
    ~LibCecSharp(void)
    {
-     CECDestroy(m_libCec);
+     Close();
      DestroyDelegates();
      m_libCec = NULL;
    }
@@ -597,7 +596,7 @@ public:
 protected:
    !LibCecSharp(void)
    {
-     CECDestroy(m_libCec);
+     Close();
      DestroyDelegates();
      m_libCec = NULL;
    }
@@ -951,6 +950,8 @@ public:
 private:
   void DestroyDelegates()
   {
+    m_bHasCallbacks = false;
+    delete m_callbacks;
     m_logMessageGCHandle.Free();
     m_keypressGCHandle.Free();
     m_commandGCHandle.Free();