From 95fa881e92cb5284be976d5c7267a03e5fb4c7ab Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Sat, 27 Dec 2008 17:47:55 +0000 Subject: [PATCH] don't assert (and then crash) in wxEvent::Clone() checking code git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57601 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/init.cpp | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/common/init.cpp b/src/common/init.cpp index 5154c1afd7..49e211f064 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -255,28 +255,34 @@ static bool DoCommonPostInit() // the executable currently running, which are not necessarily all // wxWidgets event classes. const wxClassInfo *ci = wxClassInfo::GetFirst(); - while (ci) + for (; ci; ci = ci->GetNext()) { // is this class derived from wxEvent? - if (ci->IsKindOf(CLASSINFO(wxEvent)) && wxString(ci->GetClassName()) != "wxEvent") - { - if (!ci->IsDynamic()) - wxLogWarning("The event class '%s' should have a DECLARE_DYNAMIC_CLASS macro!", - ci->GetClassName()); - - // yes; test if it implements Clone() correctly - wxEvent* test = dynamic_cast(ci->CreateObject()); - wxASSERT_MSG(test, "The event class should have a DECLARE_DYNAMIC_CLASS macro!"); + if (!ci->IsKindOf(CLASSINFO(wxEvent)) || wxString(ci->GetClassName()) == "wxEvent") + continue; - wxEvent* cloned = test->Clone(); - if (!cloned || cloned->GetClassInfo() != ci) - wxLogWarning("The event class '%s' does not correctly implements wxEvent::Clone()!", - ci->GetClassName()); + if (!ci->IsDynamic()) + { + wxLogWarning("The event class '%s' should have a DECLARE_DYNAMIC_CLASS macro!", + ci->GetClassName()); + continue; + } - delete test; + // yes; test if it implements Clone() correctly + wxEvent* test = dynamic_cast(ci->CreateObject()); + if (test == NULL) + { + wxLogWarning("The event class '%s' should have a DECLARE_DYNAMIC_CLASS macro!", + ci->GetClassName()); + continue; } - ci = ci->GetNext(); + wxEvent* cloned = test->Clone(); + if (!cloned || cloned->GetClassInfo() != ci) + wxLogWarning("The event class '%s' does not correctly implement Clone()!", + ci->GetClassName()); + + delete test; } #endif -- 2.45.2