X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0fa541e8706f74887efeba9e475eae618873da2a..8e77fd8bca165aab9709649d79a7cbc6a172d4e1:/include/wx/persist/window.h?ds=sidebyside diff --git a/include/wx/persist/window.h b/include/wx/persist/window.h index 692e143a13..30fa88b215 100644 --- a/include/wx/persist/window.h +++ b/include/wx/persist/window.h @@ -23,25 +23,15 @@ // type-independent part of wxPersistentWindow class wxPersistentWindowBase : -#if wxEVENTS_COMPATIBILITY_2_8 - // in compatibility mode we need to derive from wxEvtHandler to be able to - // handle events - public wxEvtHandler , -#endif + wxBIND_OR_CONNECT_HACK_BASE_CLASS public wxPersistentObject { public: wxPersistentWindowBase(wxWindow *win) : wxPersistentObject(win) { - win->Connect - ( - wxEVT_DESTROY, - wxWindowDestroyEventHandler( - wxPersistentWindowBase::HandleDestroy), - NULL, - this - ); + wxBIND_OR_CONNECT_HACK(win, wxEVT_DESTROY, wxWindowDestroyEventHandler, + wxPersistentWindowBase::HandleDestroy, this); } virtual wxString GetName() const @@ -60,11 +50,16 @@ private: { event.Skip(); - // this will delete this object itself - wxPersistenceManager::Get().SaveAndUnregister(GetWindow()); + // only react to the destruction of this object itself, not of any of + // its children + if ( event.GetEventObject() == GetObject() ) + { + // this will delete this object itself + wxPersistenceManager::Get().SaveAndUnregister(GetWindow()); + } } - DECLARE_NO_COPY_CLASS(wxPersistentWindowBase) + wxDECLARE_NO_COPY_CLASS(wxPersistentWindowBase); }; template