Ensure that the root wxXmlNode is deleted by storing it in a wxScopedPtr
instead of a raw pointer.
See #11593.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67345
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
#endif // WX_PRECOMP
#include "wx/xml/xml.h"
#endif // WX_PRECOMP
#include "wx/xml/xml.h"
+#include "wx/scopedptr.h"
#include "wx/sstream.h"
#include <stdarg.h>
#include "wx/sstream.h"
#include <stdarg.h>
-void CheckXml(wxXmlNode *n, ...)
+void CheckXml(const wxScopedPtr<wxXmlNode>& n, ...)
{
va_list args;
va_start(args, n);
{
va_list args;
va_start(args, n);
CPPUNIT_ASSERT( child );
CPPUNIT_ASSERT_EQUAL( childName, child->GetName() );
CPPUNIT_ASSERT( child->GetChildren() == NULL );
CPPUNIT_ASSERT( child );
CPPUNIT_ASSERT_EQUAL( childName, child->GetName() );
CPPUNIT_ASSERT( child->GetChildren() == NULL );
- CPPUNIT_ASSERT( child->GetParent() == n );
+ CPPUNIT_ASSERT( child->GetParent() == n.get() );
child = child->GetNext();
}
child = child->GetNext();
}
void XmlTestCase::InsertChild()
{
void XmlTestCase::InsertChild()
{
- wxXmlNode *root = new wxXmlNode(wxXML_ELEMENT_NODE, "root");
+ wxScopedPtr<wxXmlNode> root(new wxXmlNode(wxXML_ELEMENT_NODE, "root"));
root->AddChild(new wxXmlNode(wxXML_ELEMENT_NODE, "1"));
wxXmlNode *two = new wxXmlNode(wxXML_ELEMENT_NODE, "2");
root->AddChild(two);
root->AddChild(new wxXmlNode(wxXML_ELEMENT_NODE, "1"));
wxXmlNode *two = new wxXmlNode(wxXML_ELEMENT_NODE, "2");
root->AddChild(two);
void XmlTestCase::InsertChildAfter()
{
void XmlTestCase::InsertChildAfter()
{
- wxXmlNode *root = new wxXmlNode(wxXML_ELEMENT_NODE, "root");
+ wxScopedPtr<wxXmlNode> root(new wxXmlNode(wxXML_ELEMENT_NODE, "root"));
root->InsertChildAfter(new wxXmlNode(wxXML_ELEMENT_NODE, "1"), NULL);
CheckXml(root, "1", NULL);
root->InsertChildAfter(new wxXmlNode(wxXML_ELEMENT_NODE, "1"), NULL);
CheckXml(root, "1", NULL);