diff --git a/docs/changes.txt b/docs/changes.txt index 516fc6a37e..6378aa55b5 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -105,6 +105,7 @@ All (Unix): All (GUI): - Allow status bar children in XRC (Edmunt Pienkowski) +- Fix memory leak in wxWizard when not using sizers for the page layout wxMSW: diff --git a/include/wx/generic/wizard.h b/include/wx/generic/wizard.h index 52940b2a82..02309299ad 100644 --- a/include/wx/generic/wizard.h +++ b/include/wx/generic/wizard.h @@ -45,6 +45,10 @@ public: long style = wxDEFAULT_DIALOG_STYLE); void Init(); +#if wxABI_VERSION >= 20804 + virtual ~wxWizard(); +#endif + // implement base class pure virtuals virtual bool RunWizard(wxWizardPage *firstPage); virtual wxWizardPage *GetCurrentPage() const; diff --git a/src/generic/wizard.cpp b/src/generic/wizard.cpp index 385a10d8b8..01eed934a5 100644 --- a/src/generic/wizard.cpp +++ b/src/generic/wizard.cpp @@ -326,6 +326,15 @@ bool wxWizard::Create(wxWindow *parent, return result; } +wxWizard::~wxWizard() +{ + // normally we don't have to delete this sizer as it's deleted by the + // associated window but if we never used it or didn't set it as the window + // sizer yet, do delete it manually + if ( !m_usingSizer || !m_started ) + delete m_sizerPage; +} + void wxWizard::AddBitmapRow(wxBoxSizer *mainColumn) { m_sizerBmpAndPage = new wxBoxSizer(wxHORIZONTAL);