X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e0f0b19775b1d04f6f356b1a3edb30d4b845e649..dfe8399aa013a1fa6487d008bf1176078f218c6d:/src/common/object.cpp diff --git a/src/common/object.cpp b/src/common/object.cpp index 1fe178f04f..776878d214 100644 --- a/src/common/object.cpp +++ b/src/common/object.cpp @@ -151,8 +151,27 @@ 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, + wxString::Format + ( + _T("base class '%s' is unknown to wxWindows RTTI"), + name + ) ); + 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 +204,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()); } } @@ -230,6 +247,10 @@ void wxObject::Ref(const wxObject& clone) DEBUG_PRINTF(wxObject::Ref) #endif + // nothing to be done + if (m_refData == clone.m_refData) + return; + // delete reference to old data UnRef(); @@ -262,7 +283,7 @@ void wxObject::AllocExclusive() else if ( m_refData->GetRefCount() > 1 ) { // note that ref is not going to be destroyed in this case - wxObjectRefData* ref = m_refData; + const wxObjectRefData* ref = m_refData; UnRef(); // ... so we can still access it @@ -282,7 +303,8 @@ wxObjectRefData *wxObject::CreateRefData() const return NULL; } -wxObjectRefData *wxObject::CloneRefData(const wxObjectRefData * WXUNUSED(data)) const +wxObjectRefData * +wxObject::CloneRefData(const wxObjectRefData * WXUNUSED(data)) const { // if you use AllocExclusive() you must override this method wxFAIL_MSG( _T("CloneRefData() must be overridden if called!") );