From faf730d5f7247e8c68373c44c38d59231e0e0f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Tue, 30 Sep 2003 18:37:12 +0000 Subject: [PATCH] XML code fixes (patch #815196 -- backported to 2.4) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@24013 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/src/xrc/xml.cpp | 16 ++++++++++++---- src/xrc/xml.cpp | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/contrib/src/xrc/xml.cpp b/contrib/src/xrc/xml.cpp index 0382c121ec..62abce457a 100644 --- a/contrib/src/xrc/xml.cpp +++ b/contrib/src/xrc/xml.cpp @@ -538,8 +538,10 @@ bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding) done = (len < BUFSIZE); if (!XML_Parse(parser, buf, len, done)) { + wxString error(XML_ErrorString(XML_GetErrorCode(parser)), + *wxConvCurrent); wxLogError(_("XML parsing error: '%s' at line %d"), - XML_ErrorString(XML_GetErrorCode(parser)), + error.c_str(), XML_GetCurrentLineNumber(parser)); ok = FALSE; break; @@ -548,10 +550,16 @@ bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding) if (ok) { - SetVersion(ctx.version); - SetFileEncoding(ctx.encoding); + if (!ctx.version.IsEmpty()) + SetVersion(ctx.version); + if (!ctx.encoding.IsEmpty()) + SetFileEncoding(ctx.encoding); SetRoot(ctx.root); } + else + { + delete ctx.root; + } XML_ParserFree(parser); #if !wxUSE_UNICODE @@ -575,7 +583,7 @@ inline static void OutputString(wxOutputStream& stream, const wxString& str, { if (str.IsEmpty()) return; #if wxUSE_UNICODE - const wxWX2MBbuf buf(str.mb_str(convFile ? *convFile : wxConvUTF8)); + const wxWX2MBbuf buf(str.mb_str(*(convFile ? convFile : &wxConvUTF8))); stream.Write((const char*)buf, strlen((const char*)buf)); #else if ( convFile == NULL ) diff --git a/src/xrc/xml.cpp b/src/xrc/xml.cpp index 0382c121ec..62abce457a 100644 --- a/src/xrc/xml.cpp +++ b/src/xrc/xml.cpp @@ -538,8 +538,10 @@ bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding) done = (len < BUFSIZE); if (!XML_Parse(parser, buf, len, done)) { + wxString error(XML_ErrorString(XML_GetErrorCode(parser)), + *wxConvCurrent); wxLogError(_("XML parsing error: '%s' at line %d"), - XML_ErrorString(XML_GetErrorCode(parser)), + error.c_str(), XML_GetCurrentLineNumber(parser)); ok = FALSE; break; @@ -548,10 +550,16 @@ bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding) if (ok) { - SetVersion(ctx.version); - SetFileEncoding(ctx.encoding); + if (!ctx.version.IsEmpty()) + SetVersion(ctx.version); + if (!ctx.encoding.IsEmpty()) + SetFileEncoding(ctx.encoding); SetRoot(ctx.root); } + else + { + delete ctx.root; + } XML_ParserFree(parser); #if !wxUSE_UNICODE @@ -575,7 +583,7 @@ inline static void OutputString(wxOutputStream& stream, const wxString& str, { if (str.IsEmpty()) return; #if wxUSE_UNICODE - const wxWX2MBbuf buf(str.mb_str(convFile ? *convFile : wxConvUTF8)); + const wxWX2MBbuf buf(str.mb_str(*(convFile ? convFile : &wxConvUTF8))); stream.Write((const char*)buf, strlen((const char*)buf)); #else if ( convFile == NULL )