wxXmlResource::wxXmlResource(int flags)
{
- m_handlers.DeleteContents(TRUE);
m_flags = flags;
m_version = -1;
}
{
m_flags = flags;
m_version = -1;
- m_handlers.DeleteContents(TRUE);
Load(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
}
# undef wxXmlFindFirst
# undef wxXmlFindNext
- return rt;
+ return rt && UpdateResources();
}
void wxXmlResource::ClearHandlers()
{
- m_handlers.Clear();
+ WX_CLEAR_LIST(wxList, m_handlers);
}
-void wxXmlResource::UpdateResources()
+bool wxXmlResource::UpdateResources()
{
+ bool rt = true;
bool modif;
# if wxUSE_FILESYSTEM
wxFSFile *file = NULL;
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;
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
{
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();
# endif
}
}
+
+ return rt;
}
}
else if (node->GetName() == wxT("object"))
{
- wxNode *ND = m_handlers.GetFirst();
+ wxList::compatibility_iterator ND = m_handlers.GetFirst();
while (ND)
{
handler = (wxXmlResourceHandler*)ND->GetData();
if (!ms_subclassFactories)
{
ms_subclassFactories = new wxXmlSubclassFactoriesList;
- ms_subclassFactories->DeleteContents(TRUE);
}
ms_subclassFactories->Append(factory);
}
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);
void OnExit()
{
delete wxXmlResource::Set(NULL);
+ if(wxXmlResource::ms_subclassFactories)
+ WX_CLEAR_LIST(wxXmlSubclassFactoriesList, *wxXmlResource::ms_subclassFactories);
wxDELETE(wxXmlResource::ms_subclassFactories);
CleanXRCID_Records();
}