]> git.saurik.com Git - wxWidgets.git/commitdiff
1) now associated drop target is deleted (memory/resource leak corrected)
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 27 May 1998 23:36:40 +0000 (23:36 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 27 May 1998 23:36:40 +0000 (23:36 +0000)
2) added wxCHECK( hWnd != NULL ) to wxAssociateWinWithHandle

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/window.cpp

index 3c3728462ad1d7e83204fcc0d6c33ed532777e53..4f8b2a65588c6947095975ffa9589b349a0956dd 100644 (file)
@@ -303,8 +303,6 @@ wxWindow::~wxWindow(void)
   // wxWnd
   MSWDetachWindowMenu();
 
-  wxRemoveHandleAssociation(this);
-
   // TODO for backward compatibility
 #if 0
   // WX_CANVAS
@@ -325,6 +323,8 @@ wxWindow::~wxWindow(void)
 
   if (m_hWnd)
     ::DestroyWindow((HWND)m_hWnd);
+
+  wxRemoveHandleAssociation(this);
   m_hWnd = 0;
 #ifndef __WIN32__
   if (m_globalHandle)
@@ -566,7 +566,11 @@ wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler)
 
 void wxWindow::SetDropTarget(wxDropTarget *pDropTarget)
 {
-  DELETEP(m_pDropTarget);
+  if ( m_pDropTarget != 0 ) {
+    m_pDropTarget->Revoke(m_hWnd);
+    delete m_pDropTarget;
+  }
+
   m_pDropTarget = pDropTarget;
   if ( m_pDropTarget != 0 )
     m_pDropTarget->Register(m_hWnd);
@@ -1538,6 +1542,10 @@ wxWindow *wxFindWinFromHandle(WXHWND hWnd)
 
 void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win)
 {
+  // adding NULL hWnd is (first) surely a result of an error and
+  // (secondly) breaks menu command processing
+  wxCHECK( hWnd != NULL );
+
   if ( !wxWinHandleList->Find((long)hWnd) )
     wxWinHandleList->Append((long)hWnd, win);
 }
@@ -1680,15 +1688,15 @@ bool wxWindow::MSWOnDestroy(void)
 #if DEBUG > 1
   wxDebugMsg("wxWindow::MSWOnDestroy %d\n", handle);
 #endif
-  // delete our log target if we've got one
-#if USE_DRAG_AND_DROP
-    if ( m_pDropTarget != 0 ) {
+  // delete our drop target if we've got one
+  #if USE_DRAG_AND_DROP
+    if ( m_pDropTarget != NULL ) {
       m_pDropTarget->Revoke(m_hWnd);
 
       delete m_pDropTarget;
       m_pDropTarget = NULL;
     }
-#endif
+  #endif
 
   return TRUE;
 }