initialize wxClassInfo::sm_classTable automatically

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22626 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2003-08-06 10:44:48 +00:00
parent 14fc7eb426
commit d1d738f18c
5 changed files with 68 additions and 104 deletions

View File

@@ -159,16 +159,6 @@ void wxPluginLibrary::UpdateClassInfo()
(*ms_classes)[info->m_className] = this;
}
}
#if wxUSE_EXTENDED_RTTI == 0
for(info = m_after; info != m_before; info = info->m_next)
{
if( info->m_baseClassName1 )
info->m_baseInfo1 = (wxClassInfo *)t->Get(info->m_baseClassName1);
if( info->m_baseClassName2 )
info->m_baseInfo2 = (wxClassInfo *)t->Get(info->m_baseClassName2);
}
#endif
}
void wxPluginLibrary::RestoreClassInfo()
@@ -531,7 +521,7 @@ void wxLibrary::PrepareClasses(wxClassInfo *first)
info = info->m_next;
}
#if wxUSE_EXTENDED_RTTI == 0
#if !wxUSE_EXTENDED_RTTI
// Set base pointers for each wxClassInfo
info = first;
while (info)

View File

@@ -194,9 +194,7 @@ wxClassInfo::~wxClassInfo()
info = info->m_next;
}
}
#if wxUSE_EXTENDED_RTTI
Unregister( m_className ) ;
#endif
Unregister();
}
wxClassInfo *wxClassInfo::FindClass(const wxChar *className)
@@ -217,30 +215,6 @@ wxClassInfo *wxClassInfo::FindClass(const wxChar *className)
}
}
// a tiny InitializeClasses() helper
/* static */
inline wxClassInfo *wxClassInfo::GetBaseByName(const wxChar *name)
{
if ( !name )
return NULL;
wxClassInfo *classInfo = (wxClassInfo *)sm_classTable->Get(name);
#ifdef __WXDEBUG__
// this must be fixed, other things will work wrongly later if you get this
if ( !classInfo )
{
wxFAIL_MSG( wxString::Format
(
_T("base class '%s' is unknown to wxWindows RTTI"),
name
) );
}
#endif // __WXDEBUG__
return classInfo;
}
// Set pointers to base class(es) to speed up IsKindOf
void wxClassInfo::InitializeClasses()
{
@@ -255,30 +229,24 @@ void wxClassInfo::InitializeClasses()
size_t nClass = 0;
#endif
sm_classTable = new wxHashTable(wxKEY_STRING);
// Index all class infos by their class name
wxClassInfo *info;
for(info = sm_first; info; info = info->m_next)
// Do this initialization only once, because classes are added
// automatically if
if ( sm_classTable == NULL )
{
if (info->m_className)
sm_classTable = new wxHashTable(wxKEY_STRING);
// Index all class infos by their class name:
wxClassInfo *info;
for(info = sm_first; info; info = info->m_next)
{
wxASSERT_MSG( ++nClass < nMaxClasses,
_T("an infinite loop detected - have you used IMPLEMENT_DYNAMIC_CLASS() twice (may be by linking some object module(s) twice)?") );
sm_classTable->Put(info->m_className, (wxObject *)info);
if (info->m_className)
{
wxASSERT_MSG( ++nClass < nMaxClasses,
_T("an infinite loop detected - have you used IMPLEMENT_DYNAMIC_CLASS() twice (may be by linking some object module(s) twice)?") );
sm_classTable->Put(info->m_className, (wxObject *)info);
}
}
}
#if wxUSE_EXTENDED_RTTI == 0
// Set base pointers for each wxClassInfo
for(info = sm_first; info; info = info->m_next)
{
info->m_baseInfo1 = GetBaseByName(info->GetBaseClassName1());
info->m_baseInfo2 = GetBaseByName(info->GetBaseClassName2());
}
#endif
}
void wxClassInfo::CleanUpClasses()
@@ -287,6 +255,22 @@ void wxClassInfo::CleanUpClasses()
wxClassInfo::sm_classTable = NULL;
}
void wxClassInfo::Register()
{
if ( sm_classTable )
{
sm_classTable->Put(m_className, (wxObject *)this);
}
}
void wxClassInfo::Unregister()
{
if ( sm_classTable )
{
sm_classTable->Delete(m_className);
}
}
wxObject *wxCreateDynamicObject(const wxChar *name)
{
#if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT

View File

@@ -548,24 +548,6 @@ void wxSetStringToArray( const wxString &s , wxArrayString &array )
// wxClassInfo
// ----------------------------------------------------------------------------
void wxClassInfo::Register(const char *WXUNUSED(name), wxClassInfo *WXUNUSED(info))
{
/*
if (!ExtendedTypeMap)
ExtendedTypeMap = new ClassMap;
(*ExtendedTypeMap)[string(Name)] = Info;
*/
}
void wxClassInfo::Unregister(const char *WXUNUSED(name))
{
/*
assert(ExtendedTypeMap);
ExtendedTypeMap->erase(Name);
*/
}
const wxPropertyAccessor *wxClassInfo::FindAccessor(const char *PropertyName)
{
const wxPropertyInfo* info = FindPropertyInfo( PropertyName ) ;