]> git.saurik.com Git - wxWidgets.git/commitdiff
log changes
authorStefan Csomor <csomor@advancedconcepts.ch>
Thu, 4 Sep 2003 16:18:07 +0000 (16:18 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Thu, 4 Sep 2003 16:18:07 +0000 (16:18 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23380 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/object.h
include/wx/xti.h
include/wx/xtistrm.h
src/common/xti.cpp
src/common/xtistrm.cpp
src/common/xtixml.cpp

index b065d9d92baf6de341846c0b5f1ba438cabd297b..e91d7b9fe6e977f05ba40d31a472b996eaaac064 100644 (file)
@@ -537,13 +537,14 @@ inline wxObject *wxCheckDynamicCast(wxObject *obj, wxClassInfo *classInfo)
 #if wxUSE_EXTENDED_RTTI
 class WXDLLIMPEXP_BASE wxDynamicObject : public wxObject
 {
+    friend class WXDLLIMPEXP_BASE wxDynamicClassInfo ;
 public:
     // instantiates this object with an instance of its superclass
     wxDynamicObject(wxObject* superClassInstance, const wxDynamicClassInfo *info) ;
     ~wxDynamicObject();
 
-    void SetProperty (const wxChar *PropertyName, const wxxVariant &Value);
-    wxxVariant GetProperty (const wxChar *PropertyName) const ;
+    void SetProperty (const wxChar *propertyName, const wxxVariant &value);
+    wxxVariant GetProperty (const wxChar *propertyName) const ;
 
     // get the runtime identity of this object
     wxClassInfo *GetClassInfo() const
@@ -556,6 +557,12 @@ public:
         return m_superClassInstance ;
     }
 private :
+    // removes an existing runtime-property
+    void RemoveProperty( const wxChar *propertyName ) ;
+
+    // renames an existing runtime-property
+    void RenameProperty( const wxChar *oldPropertyName , const wxChar *newPropertyName ) ;
+
     wxObject *m_superClassInstance ;
     const wxDynamicClassInfo *m_classInfo;
     struct wxDynamicObjectInternal;
index e6845c10cb42de30cf911668aba28aaa7921ddce..ea0873352f0f456eec8cde6c6f069d5e018fbe34 100644 (file)
@@ -42,6 +42,8 @@
 #include "wx/string.h"
 #include "wx/arrstr.h"
 #include "wx/hashmap.h"
+#include "wx/log.h"
+#include  "wx/intl.h"
 
 #include <typeinfo>
 
@@ -391,11 +393,11 @@ public :
     // convert a wxxVariant holding data of this type into a string
     void ConvertToString( const wxxVariant& data , wxString &result ) const
 
-    { wxASSERT_MSG( m_toString , wxT("String conversions not supported") ) ; (*m_toString)( data , result ) ; }
+    { if ( m_toString ) (*m_toString)( data , result ) ; else wxLogError( _("String conversions not supported") ) ; }
 
     // convert a string into a wxxVariant holding the corresponding data in this type
     void ConvertFromString( const wxString& data , wxxVariant &result ) const
-    { wxASSERT_MSG( m_fromString , wxT("String conversions not supported") ) ; (*m_fromString)( data , result ) ; }
+    { if( m_fromString ) (*m_fromString)( data , result ) ; else wxLogError( _("String conversions not supported") ) ; }
 
 #if wxUSE_UNICODE
     static wxTypeInfo        *FindType(const char *typeName) { return FindType( wxString::FromAscii(typeName) ) ; }
@@ -464,11 +466,11 @@ public :
     // convert a wxxVariant holding data of this type into a long
     void ConvertToLong( const wxxVariant& data , long &result ) const
 
-    { wxASSERT_MSG( m_toLong , wxT("Long conversions not supported") ) ; (*m_toLong)( data , result ) ; }
+    { if( m_toLong ) (*m_toLong)( data , result ) ; else wxLogError( _("Long Conversions not supported") ) ; }
 
     // convert a long into a wxxVariant holding the corresponding data in this type
     void ConvertFromLong( long data , wxxVariant &result ) const
-    { wxASSERT_MSG( m_fromLong , wxT("Long conversions not supported") ) ; (*m_fromLong)( data , result ) ; }
+    { if( m_fromLong ) (*m_fromLong)( data , result ) ; else wxLogError( _("Long Conversions not supported") ) ;}
 
 private :
     converterToLong_t m_toLong ;
@@ -536,15 +538,10 @@ template<typename T> const wxTypeInfo* wxGetTypeInfo( T * ) { return wxTypeInfo:
 #define wxCOLLECTION_TYPE_INFO( element , collection ) \
     wxCollectionTypeInfo s_typeInfo##collection( typeid(element).name() , NULL , NULL , typeid(collection).name() ) ;
 
-// sometimes a compiler invents specializations that are nowhere called, use this macro to satisfy the refs
+// sometimes a compiler invents specializations that are nowhere called, use this macro to satisfy the refs, currently
+// we don't have to play tricks, but if we will have to according to the compiler, we will use that macro for that
 
 #define wxILLEGAL_TYPE_SPECIALIZATION( a )
-/*
-    template<>  const wxTypeInfo* wxGetTypeInfo( a * ) { assert(0) ; \
-    static wxBuiltInTypeInfo s_typeInfo( wxT_VOID ) ; return &s_typeInfo ; } \
-    template<>  void wxStringReadValue(const wxString & , a & ) { assert(0) ; }\
-    template<>  void wxStringWriteValue(wxString & , a const & ) { assert(0) ; }
-*/
 
 // ----------------------------------------------------------------------------
 // wxxVariant as typesafe data holder
@@ -798,19 +795,19 @@ public :
 
     // Setting a simple property (non-collection)
     virtual void SetProperty(wxObject *object, const wxxVariant &value) const
-    { wxASSERT_MSG(m_setter,wxT("SetProperty called w/o valid setter") ) ; m_setter->Set( object , value ) ;}
+    { if ( m_setter ) m_setter->Set( object , value ) ; wxLogError( _("SetProperty called w/o valid setter") ) ;}
 
     // Getting a simple property (non-collection)
     virtual void GetProperty(const wxObject *object, wxxVariant &result) const
-    { wxASSERT_MSG(m_getter,wxT("GetProperty called w/o valid getter") ) ; m_getter->Get( object , result ) ;}
+    { if ( m_getter ) m_getter->Get( object , result ) ; else wxLogError( _("GetProperty called w/o valid getter") ) ;}
 
     // Adding an element to a collection property
     virtual void AddToPropertyCollection(wxObject *object, const wxxVariant &value) const
-    { wxASSERT_MSG(m_adder,wxT("AddToPropertyCollection called w/o valid adder") ) ; m_adder->Add( object , value ) ;}
+    { if ( m_adder ) m_adder->Add( object , value ) ; else wxLogError( _("AddToPropertyCollection called w/o valid adder") ) ;}
 
     // Getting a collection property
     virtual void GetPropertyCollection( const wxObject *obj, wxxVariantArray &result) const
-    { wxASSERT_MSG(m_collectionGetter,wxT("GetPropertyCollection called w/o valid collection getter") ) ; m_collectionGetter->Get( obj , result) ;}
+    { if ( m_collectionGetter ) m_collectionGetter->Get( obj , result) ; else wxLogError( _("GetPropertyCollection called w/o valid collection getter") ) ;}
 
     virtual bool HasSetter() const { return m_setter != NULL ; }
     virtual bool HasCollectionGetter() const { return m_collectionGetter != NULL ; }
@@ -858,11 +855,11 @@ public :
 
     // Adding an element to a collection property
     virtual void AddToPropertyCollection(wxObject *WXUNUSED(object), const wxxVariant &WXUNUSED(value)) const
-    { wxASSERT_MSG(0,wxT("AddToPropertyCollection called on a generic accessor") ) ;}
+    { wxLogError( _("AddToPropertyCollection called on a generic accessor") ) ;}
 
     // Getting a collection property
     virtual void GetPropertyCollection( const wxObject *WXUNUSED(obj), wxxVariantArray &WXUNUSED(result)) const
-    { wxASSERT_MSG(0,wxT("GetPropertyCollection called on a generic accessor") ) ;}
+    { wxLogError ( _("GetPropertyCollection called on a generic accessor") ) ;}
 private :
     struct wxGenericPropertyAccessorInternal ;
     wxGenericPropertyAccessorInternal* m_data ;
@@ -1604,7 +1601,11 @@ public:
     // direct construction call for classes that cannot construct instances via alloc/create
     wxObject *ConstructObject(int ParamCount, wxxVariant *Params) const
     {
-        wxASSERT_MSG( ParamCount == m_constructorPropertiesCount , wxT("Illegal Parameter Count for ConstructObject Method")) ;
+        if ( ParamCount != m_constructorPropertiesCount )
+        {
+            wxLogError( _("Illegal Parameter Count for ConstructObject Method") ) ;
+            return NULL ;
+        }
         wxObject *object = NULL ;
         m_constructor->Create( object , Params ) ;
         return object ;
@@ -1673,7 +1674,11 @@ public:
     // initialized
     virtual void Create (wxObject *object, int ParamCount, wxxVariant *Params) const
     {
-        wxASSERT_MSG( ParamCount == m_constructorPropertiesCount , wxT("Illegal Parameter Count for Create Method")) ;
+        if ( ParamCount != m_constructorPropertiesCount )
+        {
+            wxLogError( _("Illegal Parameter Count for Create Method") ) ;
+            return ;
+        }
         m_constructor->Create( object , Params ) ;
     }
 
@@ -1770,6 +1775,7 @@ WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxChar *name);
 
 class WXDLLIMPEXP_BASE wxDynamicClassInfo : public wxClassInfo
 {
+    friend class WXDLLIMPEXP_BASE wxDynamicObject ;
 public :
     wxDynamicClassInfo( const wxChar *_UnitName, const wxChar *_ClassName , const wxClassInfo* superClass ) ;
     virtual ~wxDynamicClassInfo() ;
@@ -1807,6 +1813,9 @@ public :
 
     // renames an existing runtime-handler
     void RenameHandler( const wxChar *oldHandlerName , const wxChar *newHandlerName ) ;
+private :
+    struct wxDynamicClassInfoInternal ;
+    wxDynamicClassInfoInternal* m_data ;
 } ;
 
 // ----------------------------------------------------------------------------
index faedcc9538eb793c80739094aa60cb1d468f0170..8289f676c9319a3629b9f05e7410e2f4c42c1106 100644 (file)
@@ -21,7 +21,7 @@
 #if wxUSE_EXTENDED_RTTI
 
 const int wxInvalidObjectID = -2 ;
-const int wxNullObjectID = -1 ;
+const int wxNullObjectID = -3 ;
 
 // Filer contains the interfaces for streaming objects in and out of XML,
 // rendering them either to objects in memory, or to code.  Note:  We
@@ -173,6 +173,8 @@ public :
     // Reads the component the reader is pointed at from the underlying format.  
     // The return value is the root object ID, which can
     // then be used to ask the depersister about that object
+    // if there was a problem you will get back wxInvalidObjectID and the current
+    // error log will carry the problems encoutered
     virtual int ReadObject( const wxString &name , wxDepersister *depersist ) = 0 ;
 
 private :
index 5e1779399ce49b7ea2181ceaf314263a00c1e1f1..21aa7a1170d59122db97d47033d4de0a0136d70f 100644 (file)
@@ -37,6 +37,7 @@
 #include "wx/beforestd.h"
 #include <map>
 #include <string>
+#include <list>
 #include "wx/afterstd.h"
 
 using namespace std ;
@@ -546,31 +547,22 @@ wxObject* wxxVariant::GetAsObject()
 // own attributes in a hash map. Like this it is possible to create the objects and
 // stream them, as if their class information was already available from compiled data
 
-// can't keep the attributes in a hash map, because if someone renames a property in
-// the class info, then things go potty later on when we try to iterate through
-// the property values by name.
-struct wxDynamicProperty__
-{
-#if wxUSE_UNICODE
-    wstring name;
-#else
-    string name;
-#endif
-    wxxVariant value;
-    wxDynamicProperty__ *next;
-};
-
 struct wxDynamicObject::wxDynamicObjectInternal
 {
-    wxDynamicObjectInternal() : m_properties(NULL) {}
-    wxDynamicProperty__ *m_properties;
-#if 0
+    wxDynamicObjectInternal() {}
+
 #if wxUSE_UNICODE
     map<wstring,wxxVariant> m_properties ;
 #else
     map<string,wxxVariant> m_properties ;
 #endif
-#endif
+} ;
+
+typedef list< wxDynamicObject* > wxDynamicObjectList ;
+
+struct wxDynamicClassInfo::wxDynamicClassInfoInternal
+{
+    wxDynamicObjectList m_dynamicObjects ;
 } ;
 
 // instantiates this object with an instance of its superclass
@@ -583,6 +575,7 @@ wxDynamicObject::wxDynamicObject(wxObject* superClassInstance, const wxDynamicCl
 
 wxDynamicObject::~wxDynamicObject()
 {
+    dynamic_cast<const wxDynamicClassInfo*>(m_classInfo)->m_data->m_dynamicObjects.remove( this ) ;
     delete m_data ;
     delete m_superClassInstance ;
 }
@@ -590,41 +583,30 @@ wxDynamicObject::~wxDynamicObject()
 void wxDynamicObject::SetProperty (const wxChar *propertyName, const wxxVariant &value)
 {
     wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),wxT("Accessing Unknown Property in a Dynamic Object") ) ;
-    wxDynamicProperty__ *prop;
-    prop = m_data->m_properties;
-    while (prop)
-    {
-       if (!strcmp(prop->name.c_str(), propertyName))
-       {
-           prop->value = value;
-           return;
-       }
-       prop = prop->next;
-    }
-    prop = new wxDynamicProperty__;
-    prop->name = propertyName;
-    prop->value = value;
-    prop->next = m_data->m_properties;
-    m_data->m_properties = prop;
-//    m_data->m_properties[propertyName] = value ;
+    m_data->m_properties[propertyName] = value ;
 }
 
 wxxVariant wxDynamicObject::GetProperty (const wxChar *propertyName) const
 {
     wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),wxT("Accessing Unknown Property in a Dynamic Object") ) ;
-    wxDynamicProperty__ *prop;
-    prop = m_data->m_properties;
-    while (prop)
-    {
-       if (!strcmp(prop->name.c_str(), propertyName))
-           return prop->value;
-       prop = prop->next;
-    }
-    // FIXME: needs to return something a little more sane here.
-    return wxxVariant();
-//    return m_data->m_properties[propertyName] ;
+    return m_data->m_properties[propertyName] ;
+}
+
+void wxDynamicObject::RemoveProperty( const wxChar *propertyName ) 
+{
+    wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),wxT("Removing Unknown Property in a Dynamic Object") ) ;
+    m_data->m_properties.erase( propertyName ) ;
 }
 
+void wxDynamicObject::RenameProperty( const wxChar *oldPropertyName , const wxChar *newPropertyName ) 
+{
+    wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(oldPropertyName),wxT("Renaming Unknown Property in a Dynamic Object") ) ;
+    wxxVariant value = m_data->m_properties[oldPropertyName] ;
+    m_data->m_properties.erase( oldPropertyName ) ;
+    m_data->m_properties[newPropertyName] = value ;
+}
+
+
 // ----------------------------------------------------------------------------
 // wxDynamiClassInfo
 // ----------------------------------------------------------------------------
@@ -634,17 +616,21 @@ wxClassInfo( unitName, className , new const wxClassInfo*[2])
 {
     GetParents()[0] = superClass ;
     GetParents()[1] = NULL ;
+    m_data = new wxDynamicClassInfoInternal ;
 }
 
 wxDynamicClassInfo::~wxDynamicClassInfo()
 {
     delete[] GetParents() ;
+    delete m_data ;
 }
 
 wxObject *wxDynamicClassInfo::AllocateObject() const
 {
     wxObject* parent = GetParents()[0]->AllocateObject() ;
-    return new wxDynamicObject( parent , this ) ;
+    wxDynamicObject *obj = new wxDynamicObject( parent , this ) ;
+    m_data->m_dynamicObjects.push_back( obj ) ;
+    return obj ;
 }
 
 void wxDynamicClassInfo::Create (wxObject *object, int paramCount, wxxVariant *params) const
@@ -699,6 +685,8 @@ void wxDynamicClassInfo::AddHandler( const wxChar *handlerName , wxObjectEventFu
 // removes an existing runtime-property
 void wxDynamicClassInfo::RemoveProperty( const wxChar *propertyName ) 
 {
+    for ( wxDynamicObjectList::iterator iter = m_data->m_dynamicObjects.begin() ; iter != m_data->m_dynamicObjects.end() ; ++iter )
+        (*iter)->RemoveProperty( propertyName ) ;
     delete FindPropertyInfoInThisClass(propertyName) ;
 }
 
@@ -715,6 +703,8 @@ void wxDynamicClassInfo::RenameProperty( const wxChar *oldPropertyName , const w
     wxASSERT_MSG( pi ,wxT("not existing property") ) ;
     pi->m_name = newPropertyName ;
     dynamic_cast<wxGenericPropertyAccessor*>(pi->GetAccessor())->RenameProperty( oldPropertyName , newPropertyName ) ;
+    for ( wxDynamicObjectList::iterator iter = m_data->m_dynamicObjects.begin() ; iter != m_data->m_dynamicObjects.end() ; ++iter )
+        (*iter)->RenameProperty( oldPropertyName , newPropertyName ) ;
 }
 
 // renames an existing runtime-handler
index 015b8a28e36e093799f4afac30bee461bdcd9008..f1a55088e80c239c060843cc7fab25db76d1b31f 100644 (file)
@@ -152,8 +152,14 @@ void wxWriter::WriteAllProperties( const wxObject * obj , const wxClassInfo* ci
     {
         wxString name = ci->GetCreateParamName(i) ;
         const wxPropertyInfo* prop = map.find(name)->second ;
-        wxASSERT_MSG( prop , wxT("Create Parameter not found in declared RTTI Parameters") ) ;
-        WriteOneProperty( obj , prop->GetDeclaringClass() , prop , persister , data ) ;
+        if ( prop )
+        {
+            WriteOneProperty( obj , prop->GetDeclaringClass() , prop , persister , data ) ;
+        }
+        else
+        {
+            wxLogError( _("Create Parameter not found in declared RTTI Parameters") ) ;
+        }
         map.erase( name ) ;
     }
 
@@ -227,19 +233,30 @@ void wxWriter::WriteOneProperty( const wxObject *obj , const wxClassInfo* ci , c
             const wxHandlerInfo *handler = NULL ;
 
             const wxEvtHandler * evSource = dynamic_cast<const wxEvtHandler *>(obj) ;
-            wxASSERT_MSG( evSource , wxT("Illegal Object Class (Non-wxEvtHandler) as Event Source") ) ;
-
-            FindConnectEntry( evSource , dti , sink , handler ) ;
-            if ( persister->BeforeWriteDelegate( this , obj , ci , pi , sink , handler ) )
+            if ( evSource )
             {
-                if ( sink != NULL && handler != NULL )
+                FindConnectEntry( evSource , dti , sink , handler ) ;
+                if ( persister->BeforeWriteDelegate( this , obj , ci , pi , sink , handler ) )
                 {
-                    DoBeginWriteProperty( pi ) ;
-                    wxASSERT_MSG( IsObjectKnown( sink ) , wxT("Streaming delegates for not already streamed objects not yet supported") ) ;
-                    DoWriteDelegate( obj , ci , pi , sink , GetObjectID( sink ) , sink->GetClassInfo() , handler ) ;
-                    DoEndWriteProperty( pi ) ;
+                    if ( sink != NULL && handler != NULL )
+                    {
+                        DoBeginWriteProperty( pi ) ;
+                        if ( IsObjectKnown( sink ) )
+                        {
+                            DoWriteDelegate( obj , ci , pi , sink , GetObjectID( sink ) , sink->GetClassInfo() , handler ) ;
+                            DoEndWriteProperty( pi ) ;
+                        }
+                        else
+                        {
+                            wxLogError( _("Streaming delegates for not already streamed objects not yet supported") ) ;
+                        }
+                    }
                 }
             }
+            else
+            {
+                wxLogError(_("Illegal Object Class (Non-wxEvtHandler) as Event Source") ) ;
+            }
         }
         else
         {
@@ -253,8 +270,14 @@ void wxWriter::WriteOneProperty( const wxObject *obj , const wxClassInfo* ci , c
             if ( pi->GetFlags() & wxPROP_ENUM_STORE_LONG )
             {
                 const wxEnumTypeInfo *eti = dynamic_cast<const wxEnumTypeInfo*>( pi->GetTypeInfo() ) ;
-                wxASSERT_MSG( eti , wxT("Type must have enum - long conversion") ) ;
-                eti->ConvertFromLong( value.Get<long>() , value ) ;
+                if ( eti )
+                {
+                    eti->ConvertFromLong( value.Get<long>() , value ) ;
+                }
+                else
+                {
+                    wxLogError( _("Type must have enum - long conversion") ) ;
+                }
             }
 
             // avoid streaming out default values
@@ -335,18 +358,41 @@ wxReader::~wxReader()
 
 wxClassInfo* wxReader::GetObjectClassInfo(int objectID)
 {
-    assert( m_data->m_classInfos.find(objectID) != m_data->m_classInfos.end() );
+    if ( objectID == wxNullObjectID || objectID == wxInvalidObjectID )
+    {
+        wxLogError( _("Invalid or Null Object ID passed to GetObjectClassInfo" ) ) ;
+        return NULL ;
+    }
+    if ( m_data->m_classInfos.find(objectID) == m_data->m_classInfos.end() )
+    {
+        wxLogError( _("Unknown Object passed to GetObjectClassInfo" ) ) ;
+        return NULL ;
+    }
     return m_data->m_classInfos[objectID] ;
 }
 
 void wxReader::SetObjectClassInfo(int objectID, wxClassInfo *classInfo )
 {
-    assert(  m_data->m_classInfos.find(objectID) == m_data->m_classInfos.end()  ) ;
+    if ( objectID == wxNullObjectID || objectID == wxInvalidObjectID )
+    {
+        wxLogError( _("Invalid or Null Object ID passed to GetObjectClassInfo" ) ) ;
+        return ;
+    }
+    if ( m_data->m_classInfos.find(objectID) != m_data->m_classInfos.end() )
+    {
+        wxLogError( _("Already Registered Object passed to SetObjectClassInfo" ) ) ;
+        return ;
+    }
     m_data->m_classInfos[objectID] = classInfo ;
 }
 
 bool wxReader::HasObjectClassInfo( int objectID )
 {
+    if ( objectID == wxNullObjectID || objectID == wxInvalidObjectID )
+    {
+        wxLogError( _("Invalid or Null Object ID passed to HasObjectClassInfo" ) ) ;
+        return NULL ;
+    }
     return m_data->m_classInfos.find(objectID) != m_data->m_classInfos.end() ;
 }
 
@@ -372,15 +418,23 @@ struct wxRuntimeDepersister::wxRuntimeDepersisterInternal
 
     void SetObject(int objectID, wxObject *obj )
     {
-        assert(  m_objects.find(objectID) == m_objects.end()  ) ;
+        if ( m_objects.find(objectID) != m_objects.end() )
+        {
+            wxLogError( _("Passing a already registered object to SetObject") ) ;
+            return  ;
+        }
         m_objects[objectID] = obj ;
     }
     wxObject* GetObject( int objectID )
     {
         if ( objectID == wxNullObjectID )
             return NULL ;
+        if ( m_objects.find(objectID) == m_objects.end() )
+        {
+            wxLogError( _("Passing an unkown object to GetObject") ) ;
+            return NULL ;
+        }
 
-        assert(  m_objects.find(objectID) != m_objects.end()  ) ;
         return m_objects[objectID] ;
     }
 } ;
@@ -582,15 +636,24 @@ struct wxCodeDepersister::wxCodeDepersisterInternal
 
     void SetObjectName(int objectID, const wxString &name )
     {
-        assert(  m_objectNames.find(objectID) == m_objectNames.end()  ) ;
+        if ( m_objectNames.find(objectID) != m_objectNames.end() )
+        {
+            wxLogError( _("Passing a already registered object to SetObjectName") ) ;
+            return  ;
+        }
         m_objectNames[objectID] = (const wxChar *)name;
     }
+
     wxString GetObjectName( int objectID )
     {
         if ( objectID == wxNullObjectID )
             return wxT("NULL") ;
 
-        assert(  m_objectNames.find(objectID) != m_objectNames.end()  ) ;
+        if ( m_objectNames.find(objectID) == m_objectNames.end() )
+        {
+            wxLogError( _("Passing an unkown object to GetObject") ) ;
+            return wxEmptyString ;
+        }
         return wxString( m_objectNames[objectID].c_str() ) ;
     }
 } ;
@@ -630,8 +693,14 @@ wxString wxCodeDepersister::ValueAsCode( const wxxVariant &param )
     if ( type->GetKind() == wxT_CUSTOM )
     {
         const wxCustomTypeInfo* cti = dynamic_cast<const wxCustomTypeInfo*>(type) ;
-        wxASSERT_MSG( cti , wxT("Internal error, illegal wxCustomTypeInfo") ) ;
-        value.Printf( wxT("%s(%s)"), cti->GetTypeName().c_str(),param.GetAsString().c_str() );
+        if ( cti )
+        {
+            value.Printf( wxT("%s(%s)"), cti->GetTypeName().c_str(),param.GetAsString().c_str() );
+        }
+        else
+        {
+            wxLogError ( _("Internal error, illegal wxCustomTypeInfo") ) ;
+        }
     }
     else if ( type->GetKind() == wxT_STRING )
     {
@@ -759,12 +828,18 @@ void wxCodeDepersister::SetConnect(int eventSourceObjectID,
     wxString ehsink = m_data->GetObjectName(eventSinkObjectID) ;
     wxString ehsinkClass = eventSinkClassInfo->GetClassName() ;
     const wxDelegateTypeInfo *delegateTypeInfo = dynamic_cast<const wxDelegateTypeInfo*>(delegateInfo->GetTypeInfo());
-    wxASSERT_MSG(delegateTypeInfo, "delegate has no type info");
-    int eventType = delegateTypeInfo->GetEventType() ;
-    wxString handlerName = handlerInfo->GetName() ;
+    if ( delegateTypeInfo )
+    {
+        int eventType = delegateTypeInfo->GetEventType() ;
+        wxString handlerName = handlerInfo->GetName() ;
 
-    m_fp->WriteString( wxString::Format(  wxT("\t%s->Connect( %s->GetId() , %d , (wxObjectEventFunction)(wxEventFunction) & %s::%s , NULL , %s ) ;") ,
-        ehsource.c_str() , ehsource.c_str() , eventType , ehsinkClass.c_str() , handlerName.c_str() , ehsink.c_str() ) );
+        m_fp->WriteString( wxString::Format(  wxT("\t%s->Connect( %s->GetId() , %d , (wxObjectEventFunction)(wxEventFunction) & %s::%s , NULL , %s ) ;") ,
+            ehsource.c_str() , ehsource.c_str() , eventType , ehsinkClass.c_str() , handlerName.c_str() , ehsink.c_str() ) );
+    }
+    else
+    {
+        wxLogError(_("delegate has no type info"));
+    }
 }
 
 #include <wx/arrimpl.cpp>
index 08a895415ac6b38967301b30282c9c7de43a11e1..3bd916c1902644d134aab7732924a2634c8bbde5 100644 (file)
@@ -226,8 +226,15 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks)
         if (node->GetPropVal(wxT("href") , &ObjectIdString ) )
         {
             objectID = atoi( ObjectIdString.ToAscii() ) ;
-            wxASSERT_MSG( HasObjectClassInfo( objectID ) , wxT("Forward hrefs are not supported") ) ;
-            return objectID ;
+            if ( HasObjectClassInfo( objectID ) )
+            {
+                return objectID ;
+            }
+            else
+            {
+                wxLogError( _("Forward hrefs are not supported") ) ;
+                return wxInvalidObjectID ;                
+            }
         }
         if ( !node->GetPropVal(wxT("id") , &ObjectIdString ) )
         {
@@ -240,17 +247,30 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks)
         return wxInvalidObjectID;
     }
     classInfo = wxClassInfo::FindClass(className);
-    wxASSERT_MSG( classInfo , wxString::Format(wxT("unknown class %s"),className ) ) ;
-    wxASSERT_MSG( !children || children->GetType() != wxXML_TEXT_NODE , wxT("objects cannot have XML Text Nodes") ) ;
+    if ( classInfo == NULL )
+    {
+        wxLogError( wxString::Format(_("unknown class %s"),className ) ) ;
+        return wxInvalidObjectID ;
+    }
+
+    if ( children != NULL && children->GetType() == wxXML_TEXT_NODE )
+    {
+        wxLogError(_("objects cannot have XML Text Nodes") ) ; 
+        return wxInvalidObjectID;
+    }
     if (!node->GetPropVal(wxT("id"), &ObjectIdString))
     {
-        wxASSERT_MSG(0,wxT("Objects must have an id attribute") ) ;
+        wxLogError(_("Objects must have an id attribute") ) ;
         // No object id.  Eek. FIXME: error handling
         return wxInvalidObjectID;
     }
     objectID = atoi( ObjectIdString.ToAscii() ) ;
     // is this object already has been streamed in, return it here
-    wxASSERT_MSG( !HasObjectClassInfo( objectID ) , wxString::Format(wxT("Doubly used id : %d"), objectID ) ) ;
+    if ( HasObjectClassInfo( objectID ) )
+    {
+        wxLogError ( wxString::Format(_("Doubly used id : %d"), objectID ) ) ; 
+        return wxInvalidObjectID ;
+    }
 
     // new object, start with allocation
     // first make the object know to our internal registry
@@ -299,7 +319,10 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks)
         const wxChar* paramName = classInfo->GetCreateParamName(i) ;
         PropertyNodes::iterator propiter = propertyNodes.find( paramName ) ;
         const wxPropertyInfo* pi = classInfo->FindPropertyInfo( paramName ) ;
-        wxASSERT_MSG(pi,wxString::Format(wxT("Unkown Property %s"),paramName) ) ;
+        if ( pi == 0 )
+        {
+            wxLogError( wxString::Format(_("Unkown Property %s"),paramName) ) ;
+        }
         // if we don't have the value of a create param set in the xml
         // we use the default value
         if ( propiter != propertyNodes.end() )
@@ -317,11 +340,16 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks)
                 if( pi->GetFlags() & wxPROP_ENUM_STORE_LONG )
                 {
                     const wxEnumTypeInfo *eti = dynamic_cast<const wxEnumTypeInfo*>( pi->GetTypeInfo() ) ;
-                    wxASSERT_MSG( eti , wxT("Type must have enum - long conversion") ) ;
-
-                    long realval ;
-                    eti->ConvertToLong( createParams[i]  , realval ) ;
-                    createParams[i] = wxxVariant( realval ) ;
+                    if ( eti )
+                    {
+                        long realval ;
+                        eti->ConvertToLong( createParams[i]  , realval ) ;
+                        createParams[i] = wxxVariant( realval ) ;
+                    }
+                    else
+                    {
+                        wxLogError( _("Type must have enum - long conversion") ) ;
+                    }
                 }
                 createClassInfos[i] = NULL ;
             }
@@ -376,7 +404,11 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks)
                     const wxTypeInfo * elementType = collType->GetElementType() ;
                     while( prop )
                     {
-                        wxASSERT_MSG(prop->GetName() == wxT("element") , wxT("A non empty collection must consist of 'element' nodes")) ;
+                        if ( prop->GetName() != wxT("element") )
+                        {
+                            wxLogError( _("A non empty collection must consist of 'element' nodes" ) ) ;
+                            break ;
+                        }
                         wxXmlNode* elementContent = prop->GetChildren() ;
                         if ( elementContent )
                         {
@@ -433,13 +465,19 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks)
                     {
                         wxString resstring = prop->GetContent() ;
                         wxInt32 pos = resstring.Find('.') ;
-                        assert( pos != wxNOT_FOUND ) ;
-                        int sinkOid = atol(resstring.Left(pos).ToAscii()) ;
-                        wxString handlerName = resstring.Mid(pos+1) ;
-                        wxClassInfo* sinkClassInfo = GetObjectClassInfo( sinkOid ) ;
+                        if ( pos != wxNOT_FOUND )
+                        {
+                            int sinkOid = atol(resstring.Left(pos).ToAscii()) ;
+                            wxString handlerName = resstring.Mid(pos+1) ;
+                            wxClassInfo* sinkClassInfo = GetObjectClassInfo( sinkOid ) ;
 
-                        callbacks->SetConnect( objectID , classInfo , pi , sinkClassInfo ,
-                            sinkClassInfo->FindHandlerInfo(handlerName) ,  sinkOid ) ;
+                            callbacks->SetConnect( objectID , classInfo , pi , sinkClassInfo ,
+                                sinkClassInfo->FindHandlerInfo(handlerName) ,  sinkOid ) ;
+                        }
+                        else
+                        {
+                            wxLogError( _("incorrect event handler string, missing dot") ) ;
+                        }
                     }
 
                 }
@@ -449,11 +487,16 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks)
                     if( pi->GetFlags() & wxPROP_ENUM_STORE_LONG )
                     {
                         const wxEnumTypeInfo *eti = dynamic_cast<const wxEnumTypeInfo*>( pi->GetTypeInfo() ) ;
-                        wxASSERT_MSG( eti , wxT("Type must have enum - long conversion") ) ;
-
-                        long realval ;
-                        eti->ConvertToLong( nodeval , realval ) ;
-                        nodeval = wxxVariant( realval ) ;
+                        if ( eti )
+                        {
+                            long realval ;
+                            eti->ConvertToLong( nodeval , realval ) ;
+                            nodeval = wxxVariant( realval ) ;
+                        }
+                        else
+                        {
+                            wxLogError( _("Type must have enum - long conversion") ) ;
+                        }
                     }
                     callbacks->SetProperty( objectID, classInfo ,pi , nodeval ) ;
                 }