]> git.saurik.com Git - wxWidgets.git/blobdiff - src/xrc/xmlres.cpp
Applied patch [ 846809 ] Cleaning of 11 samples
[wxWidgets.git] / src / xrc / xmlres.cpp
index 36d3989fc2ea243d724f8314be305be6ab01d49b..75875474085725fec097df51f38ec142f1d901b3 100644 (file)
@@ -60,7 +60,6 @@ wxXmlResource *wxXmlResource::ms_instance = NULL;
 
 wxXmlResource::wxXmlResource(int flags)
 {
-    m_handlers.DeleteContents(TRUE);
     m_flags = flags;
     m_version = -1;
 }
@@ -69,7 +68,6 @@ wxXmlResource::wxXmlResource(const wxString& filemask, int flags)
 {
     m_flags = flags;
     m_version = -1;
-    m_handlers.DeleteContents(TRUE);
     Load(filemask);
 }
 
@@ -124,8 +122,7 @@ bool wxXmlResource::Load(const wxString& filemask)
         if (fnd.Lower().Matches(wxT("*.zip")) ||
             fnd.Lower().Matches(wxT("*.xrs")))
         {
-            wxString url(wxFileSystem::FileNameToURL(fnd));
-            rt = rt && Load(url + wxT("#zip:*.xrc"));
+            rt = rt && Load(fnd + wxT("#zip:*.xrc"));
         }
         else
 #endif
@@ -142,7 +139,7 @@ bool wxXmlResource::Load(const wxString& filemask)
     }
 #   undef wxXmlFindFirst
 #   undef wxXmlFindNext
-    return rt;
+    return rt && UpdateResources();
 }
 
 
@@ -164,7 +161,7 @@ void wxXmlResource::InsertHandler(wxXmlResourceHandler *handler)
 
 void wxXmlResource::ClearHandlers()
 {
-    m_handlers.Clear();
+    WX_CLEAR_LIST(wxList, m_handlers);
 }
 
 
@@ -321,8 +318,9 @@ static void ProcessPlatformProperty(wxXmlNode *node)
 
 
 
-void wxXmlResource::UpdateResources()
+bool wxXmlResource::UpdateResources()
 {
+    bool rt = true;
     bool modif;
 #   if wxUSE_FILESYSTEM
     wxFSFile *file = NULL;
@@ -350,7 +348,10 @@ void wxXmlResource::UpdateResources()
             file = fsys.OpenFile(m_data[i].File);
             modif = file && file->GetModificationTime() > m_data[i].Time;
             if (!file)
+            {
                 wxLogError(_("Cannot open file '%s'."), m_data[i].File.c_str());
+                rt = false;
+            }
             wxDELETE(file);
 #           else
             modif = wxDateTime(wxFileModificationTime(m_data[i].File)) > m_data[i].Time;
@@ -379,11 +380,13 @@ void wxXmlResource::UpdateResources()
                 wxLogError(_("Cannot load resources from file '%s'."),
                            m_data[i].File.c_str());
                 wxDELETE(m_data[i].Doc);
+                rt = false;
             }
             else if (m_data[i].Doc->GetRoot()->GetName() != wxT("resource"))
             {
                 wxLogError(_("Invalid XRC resource '%s': doesn't have root node 'resource'."), m_data[i].File.c_str());
                 wxDELETE(m_data[i].Doc);
+                rt = false;
             }
             else
                        {
@@ -399,7 +402,10 @@ void wxXmlResource::UpdateResources()
                 if (m_version == -1)
                     m_version = version;
                 if (m_version != version)
+                {
                     wxLogError(_("Resource files must have same version number!"));
+                    rt = false;
+                }
 
                 ProcessPlatformProperty(m_data[i].Doc->GetRoot());
                                m_data[i].Time = file->GetModificationTime();
@@ -412,6 +418,8 @@ void wxXmlResource::UpdateResources()
 #           endif
         }
     }
+
+    return rt;
 }
 
 
@@ -576,7 +584,7 @@ wxObject *wxXmlResource::CreateResFromNode(wxXmlNode *node, wxObject *parent,
     }
     else if (node->GetName() == wxT("object"))
     {
-        wxNode *ND = m_handlers.GetFirst();
+        wxList::compatibility_iterator ND = m_handlers.GetFirst();
         while (ND)
         {
             handler = (wxXmlResourceHandler*)ND->GetData();
@@ -606,7 +614,6 @@ wxXmlSubclassFactoriesList *wxXmlResource::ms_subclassFactories = NULL;
     if (!ms_subclassFactories)
     {
         ms_subclassFactories = new wxXmlSubclassFactoriesList;
-        ms_subclassFactories->DeleteContents(TRUE);
     }
     ms_subclassFactories->Append(factory);
 }
@@ -652,7 +659,7 @@ wxObject *wxXmlResourceHandler::CreateResource(wxXmlNode *node, wxObject *parent
         wxString subclass = node->GetPropVal(wxT("subclass"), wxEmptyString);
         if (!subclass.empty())
         {
-            for (wxXmlSubclassFactoriesList::Node *i = wxXmlResource::ms_subclassFactories->GetFirst();
+            for (wxXmlSubclassFactoriesList::compatibility_iterator i = wxXmlResource::ms_subclassFactories->GetFirst();
                  i; i = i->GetNext())
             {
                 m_instance = i->GetData()->Create(subclass);
@@ -1276,6 +1283,8 @@ public:
     void OnExit()
     {
         delete wxXmlResource::Set(NULL);
+        if(wxXmlResource::ms_subclassFactories)
+            WX_CLEAR_LIST(wxXmlSubclassFactoriesList, *wxXmlResource::ms_subclassFactories);
         wxDELETE(wxXmlResource::ms_subclassFactories);
         CleanXRCID_Records();
     }