X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/edf0993cae024ed0e298608184d8dbc0063620af..3bb63e5c806e7ef549673822dc6e4d40aa9dbec9:/src/common/object.cpp diff --git a/src/common/object.cpp b/src/common/object.cpp index b3b09abf92..f0ca00964c 100644 --- a/src/common/object.cpp +++ b/src/common/object.cpp @@ -5,9 +5,9 @@ // Modified by: Ron Lee // Created: 04/01/98 // RCS-ID: $Id$ -// Copyright: (c) 1998 Julian Smart and Markus Holzem +// Copyright: (c) 1998 Julian Smart // (c) 2001 Ron Lee -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -22,7 +22,8 @@ #endif #ifndef WX_PRECOMP -#include "wx/hash.h" + #include "wx/hash.h" + #include "wx/object.h" #endif #include @@ -43,11 +44,22 @@ #endif #endif // __WXDEBUG__ || wxUSE_DEBUG_CONTEXT +// we must disable optimizations for VC.NET because otherwise its too eager +// linker discards wxClassInfo objects in release build thus breaking many, +// many things +#if defined __VISUALC__ && __VISUALC__ >= 1300 + #pragma optimize("", off) +#endif wxClassInfo wxObject::sm_classwxObject( wxT("wxObject"), 0, 0, (int) sizeof(wxObject), (wxObjectConstructorFn) 0 ); +// restore optimizations +#if defined __VISUALC__ && __VISUALC__ >= 1300 + #pragma optimize("", on) +#endif + wxClassInfo* wxClassInfo::sm_first = NULL; wxHashTable* wxClassInfo::sm_classTable = NULL; @@ -82,7 +94,6 @@ void wxObject::Dump(wxSTD ostream& str) #endif - #ifdef _WX_WANT_NEW_SIZET_WXCHAR_INT void *wxObject::operator new ( size_t size, const wxChar *fileName, int lineNum ) { @@ -137,6 +148,31 @@ void wxObject::operator delete[] (void * buf, const wxChar* WXUNUSED(fileName), // wxClassInfo // ---------------------------------------------------------------------------- +wxClassInfo::~wxClassInfo() +{ + // remove this object from the linked list of all class infos: if we don't + // do it, loading/unloading a DLL containing static wxClassInfo objects is + // not going to work + if ( this == sm_first ) + { + sm_first = m_next; + } + else + { + wxClassInfo *info = sm_first; + while (info) + { + if ( info->m_next == this ) + { + info->m_next = m_next; + break; + } + + info = info->m_next; + } + } +} + wxClassInfo *wxClassInfo::FindClass(const wxChar *className) { if ( sm_classTable ) @@ -164,13 +200,17 @@ inline wxClassInfo *wxClassInfo::GetBaseByName(const wxChar *name) wxClassInfo *classInfo = (wxClassInfo *)sm_classTable->Get(name); - // this must be fixed, other things risk work wrongly later if you get this - wxASSERT_MSG( classInfo, - wxString::Format - ( - _T("base class '%s' is unknown to wxWindows RTTI"), - 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; } @@ -247,9 +287,18 @@ wxObject *wxCreateDynamicObject(const wxChar *name) // ---------------------------------------------------------------------------- -// wxClassInfo +// wxObject // ---------------------------------------------------------------------------- +// Initialize ref data from another object (needed for copy constructor and +// assignment operator) +void wxObject::InitFrom(const wxObject& other) +{ + m_refData = other.m_refData; + if ( m_refData ) + m_refData->m_count++; +} + void wxObject::Ref(const wxObject& clone) { #if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT