Merge pull request #149 from milipili/xml-memory-leaks

[BUG_FIXED] fixed minor memory leak when exporting the parameters to XML.
This commit is contained in:
Don HO 2015-06-01 23:36:30 +02:00
commit ea4b409c3d

View File

@ -3386,28 +3386,28 @@ bool NppParameters::writeProjectPanelsSettings() const
TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild(TEXT("NotepadPlus"));
if (!nppRoot) return false;
TiXmlNode *projPanelRootNode = nppRoot->FirstChildElement(TEXT("ProjectPanels"));
if (projPanelRootNode)
TiXmlNode *oldProjPanelRootNode = nppRoot->FirstChildElement(TEXT("ProjectPanels"));
if (nullptr != oldProjPanelRootNode)
{
// Erase the Project Panel root
nppRoot->RemoveChild(projPanelRootNode);
nppRoot->RemoveChild(oldProjPanelRootNode);
}
// Create the Project Panel root
projPanelRootNode = new TiXmlElement(TEXT("ProjectPanels"));
TiXmlElement projPanelRootNode{TEXT("ProjectPanels")};
// Add 3 Project Panel parameters
for (int i = 0 ; i < 3 ; ++i)
{
TiXmlElement projPanelNode(TEXT("ProjectPanel"));
TiXmlElement projPanelNode{TEXT("ProjectPanel")};
(projPanelNode.ToElement())->SetAttribute(TEXT("id"), i);
(projPanelNode.ToElement())->SetAttribute(TEXT("workSpaceFile"), _workSpaceFilePathes[i]);
(projPanelRootNode->ToElement())->InsertEndChild(projPanelNode);
(projPanelRootNode.ToElement())->InsertEndChild(projPanelNode);
}
// (Re)Insert the Project Panel root
(nppRoot->ToElement())->InsertEndChild(*projPanelRootNode);
(nppRoot->ToElement())->InsertEndChild(projPanelRootNode);
return true;
}