Add static wxEventHashTable::ReconstructAll() to undo the effects of ClearAll().

Call it from wxEventTableEntryModule::OnInit() so that it is now symmetric with OnExit().


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@48332 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Elliott
2007-08-22 14:46:50 +00:00
parent cdf3fdeb89
commit aa779707d4
3 changed files with 25 additions and 1 deletions

View File

@@ -2347,6 +2347,8 @@ public:
// Clear all tables // Clear all tables
static void ClearAll(); static void ClearAll();
// Rebuild all tables
static void ReconstructAll();
protected: protected:
// Init the hash table with the entries of the static event table. // Init the hash table with the entries of the static event table.

View File

@@ -115,7 +115,11 @@ class wxEventTableEntryModule: public wxModule
DECLARE_DYNAMIC_CLASS(wxEventTableEntryModule) DECLARE_DYNAMIC_CLASS(wxEventTableEntryModule)
public: public:
wxEventTableEntryModule() {} wxEventTableEntryModule() {}
bool OnInit() { return true; } bool OnInit()
{
wxEventHashTable::ReconstructAll();
return true;
}
void OnExit() void OnExit()
{ {
wxEventHashTable::ClearAll(); wxEventHashTable::ClearAll();
@@ -850,6 +854,23 @@ void wxEventHashTable::ClearAll()
} }
} }
// Rebuild all tables if they were cleared by ClearAll
void wxEventHashTable::ReconstructAll()
{
wxEventHashTable* table = sm_first;
while (table)
{
// This will only be true if the event table was cleared.
// What we do here is basically what the constructor does.
if(table->m_eventTypeTable == NULL)
{
table->AllocEventTypeTable(EVENT_TYPE_TABLE_INIT_SIZE);
table->m_rebuildHash = true;
}
table = table->m_next;
}
}
bool wxEventHashTable::HandleEvent(wxEvent &event, wxEvtHandler *self) bool wxEventHashTable::HandleEvent(wxEvent &event, wxEvtHandler *self)
{ {
if (m_rebuildHash) if (m_rebuildHash)

View File

@@ -53,6 +53,7 @@
*wxAuiNotebook*SetSelectedFont*; *wxAuiNotebook*SetSelectedFont*;
*wxAuiNotebook*ShowWindowMenu*; *wxAuiNotebook*ShowWindowMenu*;
*wxDocument*GetUserReadableName*; *wxDocument*GetUserReadableName*;
*wxEventHashTable*ReconstructAll*;
*wxHtmlEasyPrinting*GetParentWindow*; *wxHtmlEasyPrinting*GetParentWindow*;
*wxHtmlEasyPrinting*SetParentWindow*; *wxHtmlEasyPrinting*SetParentWindow*;
*wxLog*DoCreateOnDemand*; *wxLog*DoCreateOnDemand*;