]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
fixed memory leaks when parsing
[wxWidgets.git] / src / msw / window.cpp
index 0ba56334b2825c6ca953b7fa04d55e4d2660e338..e9acd3dc698f923ccd1c3f9ade57f4cfb618cb57 100644 (file)
@@ -156,11 +156,8 @@ static void TranslateKbdEventToMouse(wxWindowMSW *win,
 // get the text metrics for the current font
 static TEXTMETRIC wxGetTextMetrics(const wxWindowMSW *win);
 
-// check if the mouse is in the window or its child
-static bool IsMouseInWindow(HWND hwnd);
-
 // wrapper around BringWindowToTop() API
-static inline wxBringWindowToTop(HWND hwnd)
+static inline void wxBringWindowToTop(HWND hwnd)
 {
 #ifdef __WXMICROWIN__
     // It seems that MicroWindows brings the _parent_ of the window to the top,
@@ -2125,7 +2122,11 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
             break;
 
         case WM_DESTROY:
-            processed = HandleDestroy();
+            // never set processed to TRUE and *always* pass WM_DESTROY to
+            // DefWindowProc() as Windows may do some internal cleanup when
+            // processing it and failing to pass the message along may cause
+            // memory and resource leaks!
+            (void)HandleDestroy();
             break;
 
         case WM_MOVE:
@@ -3020,15 +3021,16 @@ bool wxWindowMSW::HandleEndSession(bool endSession, long logOff)
     if ( !endSession )
         return FALSE;
 
+    // only send once
+    if ( (this != wxTheApp->GetTopWindow()) )
+        return FALSE;
+
     wxCloseEvent event(wxEVT_END_SESSION, -1);
     event.SetEventObject(wxTheApp);
     event.SetCanVeto(FALSE);
     event.SetLoggingOff( (logOff == (long)ENDSESSION_LOGOFF) );
-    if ( (this == wxTheApp->GetTopWindow()) && // Only send once
-        wxTheApp->ProcessEvent(event))
-    {
-    }
-    return TRUE;
+
+    return wxTheApp->ProcessEvent(event);
 }
 
 // ---------------------------------------------------------------------------
@@ -3191,7 +3193,8 @@ bool wxWindowMSW::HandleDropFiles(WXWPARAM wParam)
 
     wxDropFilesEvent event(wxEVT_DROP_FILES, gwFilesDropped, files);
     event.m_eventObject = this;
-    event.m_pos.x = dropPoint.x; event.m_pos.x = dropPoint.y;
+    event.m_pos.x = dropPoint.x;
+    event.m_pos.y = dropPoint.y;
 
     bool rc = GetEventHandler()->ProcessEvent(event);