]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't send wxWindowDestroyEvent if we hadn't sent wxWindowCreateEvent.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 18 Apr 2011 23:36:46 +0000 (23:36 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 18 Apr 2011 23:36:46 +0000 (23:36 +0000)
Don't generate wxWindowDestroyEvent when destroying the windows that had been
never created for symmetry with wxWindowCreateEvent which wasn't sent for this
window neither.

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

src/common/wincmn.cpp

index 3e3836e68326e05290f00bc4037fc8787e595621..0b8a353c3a4c89f8b1bbe9f00a8f151a6a6589e7 100644 (file)
@@ -554,7 +554,14 @@ void wxWindowBase::SendDestroyEvent()
 
 bool wxWindowBase::Destroy()
 {
-    SendDestroyEvent();
+    // If our handle is invalid, it means that this window has never been
+    // created, either because creating it failed or, more typically, because
+    // this wxWindow object was default-constructed and its Create() method had
+    // never been called. As we didn't send wxWindowCreateEvent in this case
+    // (which is sent after successful creation), don't send the matching
+    // wxWindowDestroyEvent neither.
+    if ( GetHandle() )
+        SendDestroyEvent();
 
     delete this;