]> git.saurik.com Git - wxWidgets.git/commitdiff
assert when a base class of a class in wxRTTI system is not found
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 6 Feb 2002 01:38:48 +0000 (01:38 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 6 Feb 2002 01:38:48 +0000 (01:38 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14024 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/object.h
src/common/object.cpp

index 599bcd5fc6e5f211d036cfe2be5da98a79e47cff..d0eb3167f39d64421d6d80f8a7e990a151a3af58 100644 (file)
@@ -122,12 +122,17 @@ public:
     static wxClassInfo      *sm_first;
     wxClassInfo             *m_next;
 
+    // FIXME: this should be private (currently used directly by way too
+    //        many clients)
     static wxHashTable      *sm_classTable;
+
+private:
+    // InitializeClasses() helper
+    static wxClassInfo *GetBaseByName(const wxChar *name);
 };
 
 WXDLLEXPORT wxObject *wxCreateDynamicObject(const wxChar *name);
 
-
 // ----------------------------------------------------------------------------
 // Dynamic class macros
 // ----------------------------------------------------------------------------
index 7bf7dbdc112fe194ecb8e9e339b9be670e0ecbc0..ab3ef77b87633d04a4ed8840a4c71be2500d0172 100644 (file)
@@ -151,8 +151,22 @@ wxClassInfo *wxClassInfo::FindClass(const wxChar *className)
     }
 }
 
-    // Set pointers to base class(es) to speed up IsKindOf
+// a tiny InitializeClasses() helper
+/* static */
+inline wxClassInfo *wxClassInfo::GetBaseByName(const wxChar *name)
+{
+    if ( !name )
+        return NULL;
+
+    wxClassInfo *classInfo = (wxClassInfo *)sm_classTable->Get(name);
+
+    // this must be fixed, other things risk work wrongly later if you get this
+    wxASSERT_MSG( classInfo, _T("base class unknown to wxWindows RTTI") );
+
+    return classInfo;
+}
 
+// Set pointers to base class(es) to speed up IsKindOf
 void wxClassInfo::InitializeClasses()
 {
     // using IMPLEMENT_DYNAMIC_CLASS() macro twice (which may happen if you
@@ -185,10 +199,8 @@ void wxClassInfo::InitializeClasses()
 
     for(info = sm_first; info; info = info->m_next)
     {
-        if (info->GetBaseClassName1())
-            info->m_baseInfo1 = (wxClassInfo *)sm_classTable->Get(info->GetBaseClassName1());
-        if (info->GetBaseClassName2())
-            info->m_baseInfo2 = (wxClassInfo *)sm_classTable->Get(info->GetBaseClassName2());
+        info->m_baseInfo1 = GetBaseByName(info->GetBaseClassName1());
+        info->m_baseInfo2 = GetBaseByName(info->GetBaseClassName2());
     }
 }