From aa779707d49c4949929764caa3dc46d2ab513c1f Mon Sep 17 00:00:00 2001 From: David Elliott Date: Wed, 22 Aug 2007 14:46:50 +0000 Subject: [PATCH] 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 --- include/wx/event.h | 2 ++ src/common/event.cpp | 23 ++++++++++++++++++++++- version-script.in | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/wx/event.h b/include/wx/event.h index ffe6121079..cf72a1d80d 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -2347,6 +2347,8 @@ public: // Clear all tables static void ClearAll(); + // Rebuild all tables + static void ReconstructAll(); protected: // Init the hash table with the entries of the static event table. diff --git a/src/common/event.cpp b/src/common/event.cpp index a3e0b004e1..22f3b07bc3 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -115,7 +115,11 @@ class wxEventTableEntryModule: public wxModule DECLARE_DYNAMIC_CLASS(wxEventTableEntryModule) public: wxEventTableEntryModule() {} - bool OnInit() { return true; } + bool OnInit() + { + wxEventHashTable::ReconstructAll(); + return true; + } void OnExit() { 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) { if (m_rebuildHash) diff --git a/version-script.in b/version-script.in index e2063ed200..c7cdb4e3a6 100644 --- a/version-script.in +++ b/version-script.in @@ -53,6 +53,7 @@ *wxAuiNotebook*SetSelectedFont*; *wxAuiNotebook*ShowWindowMenu*; *wxDocument*GetUserReadableName*; + *wxEventHashTable*ReconstructAll*; *wxHtmlEasyPrinting*GetParentWindow*; *wxHtmlEasyPrinting*SetParentWindow*; *wxLog*DoCreateOnDemand*;