X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e55ad60e195f1007db921b2a73a3cac98ed9df65..6c905cb7fdc856317f1e1db9c6d6aaa93c67920c:/src/common/object.cpp?ds=sidebyside diff --git a/src/common/object.cpp b/src/common/object.cpp index a6b2ec1ca2..0eda4f7880 100644 --- a/src/common/object.cpp +++ b/src/common/object.cpp @@ -21,23 +21,34 @@ #endif #ifndef WX_PRECOMP -#include "wx/hash.h" -#ifdef USE_SERIAL -#include "wx/objstrm.h" -#include "wx/serbase.h" -#endif -#endif + #include "wx/hash.h" + #ifdef wxUSE_SERIAL + #include "wx/objstrm.h" + #include "wx/serbase.h" + + // for error messages + #include "wx/log.h" + #include "wx/intl.h" + #endif // wxUSE_SERIAL +#endif // WX_PRECOMP #include #include -#if (WXDEBUG && USE_MEMORY_TRACING) || USE_DEBUG_CONTEXT +#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT #include "wx/memory.h" #endif -#if WXDEBUG || USE_DEBUG_CONTEXT +#if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT // for wxObject::Dump - #include +#if wxUSE_IOSTREAMH +# include +#else +# include +# ifdef _MSC_VER + using namespace std; +# endif +#endif #endif #if !USE_SHARED_LIBRARY @@ -53,7 +64,7 @@ wxHashTable* wxClassInfo::sm_classTable = (wxHashTable*) NULL; wxObject::wxObject(void) { m_refData = (wxObjectRefData *) NULL; -#ifdef USE_SERIAL +#ifdef wxUSE_SERIAL m_serialObj = (wxObject_Serialize *)NULL; #endif } @@ -61,7 +72,7 @@ wxObject::wxObject(void) wxObject::~wxObject(void) { UnRef(); -#ifdef USE_SERIAL +#ifdef wxUSE_SERIAL if (m_serialObj) delete m_serialObj; #endif @@ -74,7 +85,7 @@ wxObject::~wxObject(void) * two possible base classes. */ -bool wxObject::IsKindOf(wxClassInfo *info) +bool wxObject::IsKindOf(wxClassInfo *info) const { wxClassInfo *thisInfo = GetClassInfo(); if (thisInfo) @@ -83,7 +94,7 @@ bool wxObject::IsKindOf(wxClassInfo *info) return FALSE; } -#if WXDEBUG || USE_DEBUG_CONTEXT +#if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT void wxObject::Dump(ostream& str) { if (GetClassInfo() && GetClassInfo()->GetClassName()) @@ -93,7 +104,7 @@ void wxObject::Dump(ostream& str) } #endif -#if WXDEBUG && USE_MEMORY_TRACING +#if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING #ifdef new #undef new @@ -109,8 +120,16 @@ void wxObject::operator delete (void * buf) wxDebugFree(buf); } +// VC++ 6.0 +#if _MSC_VER >= 1200 +void wxObject::operator delete(void* pData, char* /* fileName */, int /* lineNum */) +{ + ::operator delete(pData); +} +#endif + // Cause problems for VC++ - crashes -#ifndef _MSC_VER +#if !defined(_MSC_VER) && wxUSE_ARRAY_MEMORY_OPERATORS void * wxObject::operator new[] (size_t size, char * fileName, int lineNum) { return wxDebugAlloc(size, fileName, lineNum, TRUE, TRUE); @@ -166,7 +185,7 @@ wxClassInfo *wxClassInfo::FindClass(char *c) // Climb upwards through inheritance hierarchy. // Dual inheritance is catered for. -bool wxClassInfo::IsKindOf(wxClassInfo *info) +bool wxClassInfo::IsKindOf(wxClassInfo *info) const { if (info == NULL) return FALSE; @@ -250,7 +269,7 @@ wxObject *wxCreateDynamicObject(const char *name) return (wxObject*) NULL; } -#ifdef USE_SERIAL +#ifdef wxUSE_SERIAL #include "wx/serbase.h" #include "wx/dynlib.h" @@ -268,19 +287,17 @@ void wxObject::StoreObject( wxObjectOutputStream& stream ) wxLibrary *lib = wxTheLibraries.LoadLibrary("wxserial"); if (!lib) { - wxMessageBox("Can't load wxSerial dynamic library.", "Alert !"); + wxLogError(_("Can't load wxSerial dynamic library.")); return; } if (!m_serialObj) { m_serialObj = (WXSERIAL(wxObject) *)lib->CreateObject( obj_name ); if (!m_serialObj) { - wxString message; - - message.Printf("Can't find the serialization object (%s) for the object %s", - WXSTRINGCAST obj_name, - WXSTRINGCAST GetClassInfo()->GetClassName()); - wxMessageBox(message, "Alert !"); + wxLogError(_("Can't find the serialization object '%s' " + "for the object '%s'."), + obj_name.c_str(), + GetClassInfo()->GetClassName()); return; } m_serialObj->SetObject(this); @@ -298,12 +315,10 @@ void wxObject::LoadObject( wxObjectInputStream& stream ) m_serialObj = (WXSERIAL(wxObject) *)lib->CreateObject( obj_name ); if (!m_serialObj) { - wxString message; - - message.Printf("Can't find the serialization object (%s) for the object %s", - WXSTRINGCAST obj_name, - WXSTRINGCAST GetClassInfo()->GetClassName()); - wxMessageBox(message, "Alert !"); + wxLogError(_("Can't find the serialization object '%s' " + "for the object '%s'."), + obj_name.c_str(), + GetClassInfo()->GetClassName()); return; } m_serialObj->SetObject(this); @@ -352,3 +367,7 @@ wxObjectRefData::~wxObjectRefData(void) { } +// These are here so we can avoid 'always true/false' warnings +// by referring to these instead of TRUE/FALSE +const bool wxTrue = TRUE; +const bool wxFalse = FALSE;