// 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 <ron@debian.org>
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#endif
#ifndef WX_PRECOMP
-#include "wx/hash.h"
+ #include "wx/hash.h"
+ #include "wx/object.h"
#endif
#include <string.h>
#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;
#endif
-
#ifdef _WX_WANT_NEW_SIZET_WXCHAR_INT
void *wxObject::operator new ( size_t size, const wxChar *fileName, int lineNum )
{
// 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 )
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;
}
size_t nClass = 0;
#endif
- wxClassInfo::sm_classTable = new wxHashTable(wxKEY_STRING);
+ sm_classTable = new wxHashTable(wxKEY_STRING);
// Index all class infos by their class 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
// misc
// ----------------------------------------------------------------------------
-#if defined(__DARWIN__) && defined(DYLIB_INIT)
+#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
+// 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()
{
// 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();
}