fixed minor memory leak when exporting the parameters to XML
When writing the parameters as a XML file (when the application quits), a new node was created but not destroyed (`InsertEndChild` makes a clone of the given node).
This commit is contained in:
parent
17e8ca3c15
commit
25b3a712fb
@ -3401,28 +3401,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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user