X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dc5d118e65603773263040afdf2c97633869e4ca..0053219faff4714fc4a4a56ffa182e839b6070fe:/src/generic/preferencesg.cpp?ds=sidebyside diff --git a/src/generic/preferencesg.cpp b/src/generic/preferencesg.cpp index 30365e7ebc..65eeaa4b9d 100644 --- a/src/generic/preferencesg.cpp +++ b/src/generic/preferencesg.cpp @@ -33,6 +33,7 @@ #include "wx/sizer.h" #include "wx/sharedptr.h" #include "wx/scopedptr.h" +#include "wx/scopeguard.h" #include "wx/vector.h" namespace @@ -124,6 +125,8 @@ protected: dlg->AddPage(i->get()); } + dlg->Fit(); + return dlg; } @@ -193,13 +196,18 @@ class wxModalPreferencesEditorImpl : public wxGenericPreferencesEditorImplBase public: wxModalPreferencesEditorImpl() { + m_dlg = NULL; m_currentPage = -1; } virtual void Show(wxWindow* parent) { wxScopedPtr dlg(CreateDialog(parent)); - dlg->Fit(); + + // Store it for Dismiss() but ensure that the pointer is reset to NULL + // when the dialog is destroyed on leaving this function. + m_dlg = dlg.get(); + wxON_BLOCK_EXIT_NULL(m_dlg); // Restore the previously selected page, if any. if ( m_currentPage != -1 ) @@ -212,11 +220,18 @@ public: virtual void Dismiss() { - // nothing to do + if ( m_dlg ) + { + m_dlg->EndModal(wxID_CANCEL); + m_dlg = NULL; + } } private: + wxGenericPrefsDialog* m_dlg; int m_currentPage; + + wxDECLARE_NO_COPY_CLASS(wxModalPreferencesEditorImpl); }; inline