X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d1d738f18c7dbcc58604b6f3ba73ceebef656dc2..cb73e6001f891ae46b12a1e4ca39b93649cb6099:/src/common/object.cpp diff --git a/src/common/object.cpp b/src/common/object.cpp index 212f195a28..4ebc1cc9c6 100644 --- a/src/common/object.cpp +++ b/src/common/object.cpp @@ -10,7 +10,7 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "object.h" #endif @@ -33,9 +33,6 @@ #endif #if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT - // for wxObject::Dump - #include "wx/ioswrap.h" - #if defined(__VISAGECPP__) #define DEBUG_PRINTF(NAME) { static int raz=0; \ printf( #NAME " %i\n",raz); fflush(stdout); raz++; } @@ -101,17 +98,6 @@ bool wxObject::IsKindOf(wxClassInfo *info) const return (thisInfo) ? thisInfo->IsKindOf(info) : FALSE ; } -#if wxUSE_STD_IOSTREAM && (defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT) -void wxObject::Dump(wxSTD ostream& str) -{ - if (GetClassInfo() && GetClassInfo()->GetClassName()) - str << GetClassInfo()->GetClassName(); - else - str << _T("unknown object class"); -} -#endif - - #if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING && defined( new ) #undef new #endif @@ -215,52 +201,31 @@ wxClassInfo *wxClassInfo::FindClass(const wxChar *className) } } -// Set pointers to base class(es) to speed up IsKindOf -void wxClassInfo::InitializeClasses() +void wxClassInfo::CleanUp() { - // using IMPLEMENT_DYNAMIC_CLASS() macro twice (which may happen if you - // link any object module twice mistakenly) will break this function - // because it will enter an infinite loop and eventually die with "out of - // memory" - as this is quite hard to detect if you're unaware of this, - // try to do some checks here - -#ifdef __WXDEBUG__ - static const size_t nMaxClasses = 10000; // more than we'll ever have - size_t nClass = 0; -#endif - - // Do this initialization only once, because classes are added - // automatically if - if ( sm_classTable == NULL ) + if ( sm_classTable ) { - 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) - { - 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); - } - } + delete sm_classTable; + sm_classTable = NULL; } } -void wxClassInfo::CleanUpClasses() -{ - delete wxClassInfo::sm_classTable; - wxClassInfo::sm_classTable = NULL; -} - void wxClassInfo::Register() { - if ( sm_classTable ) + if ( !sm_classTable ) { - sm_classTable->Put(m_className, (wxObject *)this); + sm_classTable = new wxHashTable(wxKEY_STRING); } + + // using IMPLEMENT_DYNAMIC_CLASS() macro twice (which may happen if you + // link any object module twice mistakenly) will break this function + // because it will enter an infinite loop and eventually die with "out of + // memory" - as this is quite hard to detect if you're unaware of this, + // try to do some checks here + wxASSERT_MSG( sm_classTable->Get(m_className) == NULL, + _T("class already in RTTI table - have you used IMPLEMENT_DYNAMIC_CLASS() twice (may be by linking some object module(s) twice)?") ); + + sm_classTable->Put(m_className, (wxObject *)this); } void wxClassInfo::Unregister() @@ -268,6 +233,11 @@ void wxClassInfo::Unregister() if ( sm_classTable ) { sm_classTable->Delete(m_className); + if ( sm_classTable->GetCount() == 0 ) + { + delete sm_classTable; + sm_classTable = NULL; + } } } @@ -380,34 +350,3 @@ wxObject::CloneRefData(const wxObjectRefData * WXUNUSED(data)) const return NULL; } - -// ---------------------------------------------------------------------------- -// misc -// ---------------------------------------------------------------------------- - -#if defined(__DARWIN__) && defined(WXMAKINGDLL) - -extern "C" { - void __initialize_Cplusplus(void); - void wxWindowsDylibInit(void); -}; - -// Dynamic shared library (dylib) initialization routine -// required to initialize static C++ objects bacause of lazy dynamic linking -// http://developer.apple.com/techpubs/macosx/Essentials/ -// SystemOverview/Frameworks/Dynamic_Shared_Libraries.html - -void wxWindowsDylibInit() -{ - // The function __initialize_Cplusplus() must be called from the shared - // library initialization routine to cause the static C++ objects in - // the library to be initialized (reference number 2441683). - - // This only seems to be necessary if the library initialization routine - // needs to use the static C++ objects - __initialize_Cplusplus(); -} - -#endif - -// vi:sts=4:sw=4:et