disable clearing event tables by default, only do it if wxUSE_MEMORY_TRACING is used: this fixes the problems with events not being dispatched correctly when the library is reinitialized

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46201 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2007-05-24 23:53:05 +00:00
parent 2afb9e1690
commit a0826b119e
2 changed files with 25 additions and 22 deletions

View File

@ -2285,8 +2285,10 @@ public:
// Clear table
void Clear();
#if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING
// Clear all tables
static void ClearAll();
#endif // __WXDEBUG__ && wxUSE_MEMORY_TRACING
protected:
// Init the hash table with the entries of the static event table.

View File

@ -107,22 +107,26 @@ const wxEventTableEntry wxEvtHandler::sm_eventTableEntries[] =
{ DECLARE_EVENT_TABLE_ENTRY(wxEVT_NULL, 0, 0, (wxObjectEventFunction)NULL, NULL) };
#ifdef __WXDEBUG__
// Clear up event hash table contents or we can get problems
// when C++ is cleaning up the static object
// wxUSE_MEMORY_TRACING considers memory freed from the static objects dtors
// leaked, so we need to manually clean up all event tables before checking for
// the memory leaks when using it, however this breaks re-initializing the
// library (i.e. repeated calls to wxInitialize/wxUninitialize) because the
// event tables won't be rebuilt the next time, so disable this by default
#if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING
class wxEventTableEntryModule: public wxModule
{
DECLARE_DYNAMIC_CLASS(wxEventTableEntryModule)
public:
wxEventTableEntryModule() {}
bool OnInit() { return true; }
void OnExit()
{
wxEventHashTable::ClearAll();
}
wxEventTableEntryModule() { }
virtual bool OnInit() { return true; }
virtual void OnExit() { wxEventHashTable::ClearAll(); }
DECLARE_DYNAMIC_CLASS(wxEventTableEntryModule)
};
IMPLEMENT_DYNAMIC_CLASS(wxEventTableEntryModule, wxModule)
#endif
#endif // __WXDEBUG__ && wxUSE_MEMORY_TRACING
// ----------------------------------------------------------------------------
// global variables
@ -801,25 +805,20 @@ wxEventHashTable::~wxEventHashTable()
void wxEventHashTable::Clear()
{
size_t i;
for(i = 0; i < m_size; i++)
for ( size_t i = 0; i < m_size; i++ )
{
EventTypeTablePointer eTTnode = m_eventTypeTable[i];
if (eTTnode)
{
delete eTTnode;
}
delete eTTnode;
}
// Necessary in order to not invoke the
// overloaded delete operator when statics are cleaned up
if (m_eventTypeTable)
delete[] m_eventTypeTable;
delete[] m_eventTypeTable;
m_eventTypeTable = NULL;
m_size = 0;
}
#if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING
// Clear all tables
void wxEventHashTable::ClearAll()
{
@ -831,6 +830,8 @@ void wxEventHashTable::ClearAll()
}
}
#endif // __WXDEBUG__ && wxUSE_MEMORY_TRACING
bool wxEventHashTable::HandleEvent(wxEvent &event, wxEvtHandler *self)
{
if (m_rebuildHash)