diff --git a/docs/changes.txt b/docs/changes.txt index b9c56894ff..76e48afd50 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -117,6 +117,7 @@ All (GUI): and hiding cell cursor when it doesn't have focus. - Added alpha support to wxImage::Paste() (Steven Van Ingelgem) - Use current date when opening popup in generic wxDatePickerCtrl. +- Remove associated help text from wxHelpProvider when a window is destroyed. All (Unix): diff --git a/docs/latex/wx/helpprov.tex b/docs/latex/wx/helpprov.tex index 53b92f980e..f993057ab2 100644 --- a/docs/latex/wx/helpprov.tex +++ b/docs/latex/wx/helpprov.tex @@ -69,11 +69,16 @@ the window. \func{virtual void}{RemoveHelp}{\param{wxWindowBase* }{window}} -Removes the association between the window pointer and the help text. This is +Removes the association between the window pointer and the help text, if it +was previously set using \helpref{AddHelp}{wxhelpprovideraddhelp}. This is called by the wxWindow destructor. Without this, the table of help strings will fill up and when window pointers are reused, the wrong help string will be found. +Note that this method may be called even for windows that don't have any +associated help text. If that happens, its implementation should simply do +nothing. + \membersection{wxHelpProvider::Set}\label{wxhelpproviderset} diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index d01360f22f..dbd1079b09 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -392,6 +392,14 @@ wxWindowBase::~wxWindowBase() #if wxUSE_ACCESSIBILITY delete m_accessible; #endif + +#if wxUSE_HELP + // NB: this has to be called unconditionally, because we don't + // know whether this window has associated help text or not + wxHelpProvider *helpProvider = wxHelpProvider::Get(); + if ( helpProvider ) + helpProvider->RemoveHelp(this); +#endif } void wxWindowBase::SendDestroyEvent()