Fixed a possible double deletion of 'file'

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9830 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
George Tasker 2001-04-21 18:02:57 +00:00
parent 97af118998
commit 1600865926

View File

@ -255,7 +255,7 @@ void wxXmlResource::UpdateResources()
{
bool modif;
# if wxUSE_FILESYSTEM
wxFSFile *file;
wxFSFile *file = NULL;
wxFileSystem fsys;
# endif
@ -270,7 +270,7 @@ void wxXmlResource::UpdateResources()
modif = file && file->GetModificationTime() > m_Data[i].Time;
if (!file)
wxLogError(_("Cannot open file '%s'."), m_Data[i].File.c_str());
delete file;
wxDELETE(file);
# else
modif = wxDateTime(wxFileModificationTime(m_Data[i].File)) > m_Data[i].Time;
# endif
@ -278,11 +278,12 @@ void wxXmlResource::UpdateResources()
if (modif)
{
wxInputStream *stream;
wxInputStream *stream = NULL;
# if wxUSE_FILESYSTEM
file = fsys.OpenFile(m_Data[i].File);
stream = file->GetStream();
if (file)
stream = file->GetStream();
# else
stream = new wxFileInputStream(m_Data[i].File);
# endif
@ -295,22 +296,23 @@ void wxXmlResource::UpdateResources()
if (!stream || !m_Data[i].Doc->Load(*stream))
{
wxLogError(_("Cannot load resources from file '%s'."), m_Data[i].File.c_str());
delete m_Data[i].Doc;
m_Data[i].Doc = NULL;
wxDELETE(m_Data[i].Doc);
}
else if (m_Data[i].Doc->GetRoot()->GetName() != wxT("resource"))
{
wxLogError(_("Invalid XML resource '%s': doesn't have root node 'resource'."), m_Data[i].File.c_str());
delete m_Data[i].Doc;
m_Data[i].Doc = NULL;
wxDELETE(m_Data[i].Doc);
}
else
{
ProcessPlatformProperty(m_Data[i].Doc->GetRoot());
m_Data[i].Time = file->GetModificationTime();
}
# if wxUSE_FILESYSTEM
delete file;
wxDELETE(file);
# else
delete stream;
wxDELETE(stream);
# endif
}
}