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
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;