From 25b3a712fbbaebd99480ee2e188f316a54c99059 Mon Sep 17 00:00:00 2001 From: milipili Date: Sun, 31 May 2015 21:27:27 +0200 Subject: [PATCH] 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). --- PowerEditor/src/Parameters.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index dc5435507..141cf9e5d 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -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; }