From c170f4aeece2354e102eefe05d6d70307cbb6b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Fri, 29 Feb 2008 21:11:53 +0000 Subject: [PATCH] fixed ~wxWindowBase to remove associated context help from wxHelpProvider -- otherwise wrong help text could be reused by other controls later git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@52200 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + docs/latex/wx/helpprov.tex | 7 ++++++- src/common/wincmn.cpp | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) 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()