use shared_ptr to avoid possible memory leaks and improve exception-safety

This commit is contained in:
wmayer
2019-09-03 17:15:24 +02:00
parent 9a007cfbc4
commit f88dad0905
3 changed files with 11 additions and 14 deletions

View File

@@ -1189,8 +1189,7 @@ void Document::Restore(Base::XMLReader &reader)
void Document::RestoreDocFile(Base::Reader &reader)
{
// We must create an XML parser to read from the input stream
Base::XMLReader *localreader;
localreader = new Base::XMLReader("GuiDocument.xml", reader);
std::shared_ptr<Base::XMLReader> localreader = std::make_shared<Base::XMLReader>("GuiDocument.xml", reader);
localreader->FileVersion = reader.getFileVersion();
localreader->readElement("Document");