Added Delete member to wxStringHashTable in order to implement

wxHelpProvider::RemoveHelp, which is now called from ~wxWindowBase.
Without cleaning up the hash tables, reused window addresses will cause
the CS help to fail rather comically over time.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15754 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2002-06-05 21:06:18 +00:00
parent 4bb081fd23
commit 53e112a093
8 changed files with 102 additions and 24 deletions

View File

@@ -310,6 +310,30 @@ wxString wxStringHashTable::Get(long key, bool *wasFound) const
return _T("");
}
bool wxStringHashTable::Delete(long key) const
{
wxCHECK_MSG( m_hashSize, FALSE, _T("must call Create() first") );
size_t slot = (size_t)abs((int)(key % (long)m_hashSize));
wxArrayLong *keys = m_keys[slot];
if ( keys )
{
size_t count = keys->GetCount();
for ( size_t n = 0; n < count; n++ )
{
if ( keys->Item(n) == key )
{
keys.RemoveAt(n);
m_values[slot]->RemoveAt(n);
return TRUE;
}
}
}
return FALSE;
}
// ----------------------------------------------------------------------------
// old not type safe wxHashTable
// ----------------------------------------------------------------------------