]> git.saurik.com Git - wxWidgets.git/commitdiff
use safer RemoveEventHandler() instead of PopEventHandler() (patch 1678016)
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 16 Mar 2007 00:43:32 +0000 (00:43 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 16 Mar 2007 00:43:32 +0000 (00:43 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44842 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/mediactrl_am.cpp
src/msw/mediactrl_qt.cpp
src/msw/mediactrl_wmp10.cpp

index be49d39044e3577c92dd88b4dbadece4da2a4408..eb139307d57a983206ab9c8730212a355964c4c4 100644 (file)
@@ -1483,6 +1483,7 @@ public:
     LPAMGETERRORTEXT m_lpAMGetErrorText;
     wxString GetErrorString(HRESULT hrdsv);
 #endif // __WXDEBUG__
+    wxEvtHandler* m_evthandler;
 
     friend class wxAMMediaEvtHandler;
     DECLARE_DYNAMIC_CLASS(wxAMMediaBackend)
@@ -1573,6 +1574,7 @@ wxAMMediaBackend::wxAMMediaBackend()
 #endif
                   m_bestSize(wxDefaultSize)
 {
+   m_evthandler = NULL;
 }
 
 //---------------------------------------------------------------------------
@@ -1591,7 +1593,11 @@ wxAMMediaBackend::~wxAMMediaBackend()
         if (GetMP())
             GetMP()->Release();
 
-        m_ctrl->PopEventHandler(true);
+        if (m_evthandler)
+        {
+            m_ctrl->RemoveEventHandler(m_evthandler);
+            delete m_evthandler;
+        }
     }
 }
 
@@ -1683,7 +1689,8 @@ bool wxAMMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
 #endif
                                   );
     // Connect for events
-    m_ctrl->PushEventHandler(new wxAMMediaEvtHandler(this));
+    m_evthandler = new wxAMMediaEvtHandler(this);
+    m_ctrl->PushEventHandler(m_evthandler);
 
     //
     //  Here we set up wx-specific stuff for the default
index 406f514e480a13447a69191db92980f7a6942ba9..920ac7f9fd3a77f13ce2c4aa532d6aa2fde43e0f 100644 (file)
@@ -429,6 +429,7 @@ public:
     wxTimer* m_timer;               // Load or Play timer
     wxQuickTimeLibrary m_lib;       // DLL to load functions from
     ComponentInstance m_pMC;        // Movie Controller
+    wxEvtHandler* m_evthandler;
 
     friend class wxQTMediaEvtHandler;
 
@@ -605,6 +606,7 @@ LRESULT CALLBACK wxQTMediaBackend::QTWndProc(HWND hWnd, UINT nMsg,
 wxQTMediaBackend::wxQTMediaBackend()
 : m_movie(NULL), m_bPlaying(false), m_timer(NULL), m_pMC(NULL)
 {
+    m_evthandler = NULL;
 }
 
 //---------------------------------------------------------------------------
@@ -630,7 +632,11 @@ wxQTMediaBackend::~wxQTMediaBackend()
         }
 
         // destroy wxQTMediaEvtHandler we pushed on it
-        m_ctrl->PopEventHandler(true);
+        if (m_evthandler)
+        {
+            m_ctrl->RemoveEventHandler(m_evthandler);
+            delete m_evthandler;
+        }
 
         m_lib.DestroyPortAssociation(
             (CGrafPtr)m_lib.GetNativeWindowPort(m_ctrl->GetHWND()));
@@ -689,7 +695,8 @@ bool wxQTMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
 
     // Part of a suggestion from Greg Hazel
     // to repaint movie when idle
-    m_ctrl->PushEventHandler(new wxQTMediaEvtHandler(this, m_ctrl->GetHWND()));
+    m_evthandler = new wxQTMediaEvtHandler(this, m_ctrl->GetHWND());
+    m_ctrl->PushEventHandler(m_evthandler);
 
     // done
     return true;
index 1604899da828678e3f2e725a4b8eb7d64e69dfee..8a6f69a29d1b27766520541b7b852c808621df59 100644 (file)
@@ -675,6 +675,7 @@ public:
     wxSize m_bestSize;              // Actual movie size
 
     bool m_bWasStateChanged;        // See the "introduction"
+    wxEvtHandler* m_evthandler;
 
     friend class wxWMP10MediaEvtHandler;
     DECLARE_DYNAMIC_CLASS(wxWMP10MediaBackend)
@@ -726,6 +727,7 @@ wxWMP10MediaBackend::wxWMP10MediaBackend()
                 m_pWMPPlayer(NULL)
 
 {
+    m_evthandler = NULL;
 }
 
 //---------------------------------------------------------------------------
@@ -739,7 +741,11 @@ wxWMP10MediaBackend::~wxWMP10MediaBackend()
         m_pAX->DissociateHandle();
         delete m_pAX;
 
-        m_ctrl->PopEventHandler(true);
+        if (m_evthandler)
+        {
+            m_ctrl->RemoveEventHandler(m_evthandler);
+            delete m_evthandler;
+        }
 #else
         AtlAxWinTerm();
         _Module.Term();
@@ -812,7 +818,8 @@ bool wxWMP10MediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
     m_pAX = new wxActiveXContainer(ctrl, IID_IWMPPlayer, m_pWMPPlayer);
 
     // Connect for events
-    m_ctrl->PushEventHandler(new wxWMP10MediaEvtHandler(this));
+    m_evthandler = new wxWMP10MediaEvtHandler(this);
+    m_ctrl->PushEventHandler(m_evthandler);
 #else
     _Module.Init(NULL, ::GetModuleHandle(NULL));
     AtlAxWinInit();