summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-08-16 12:22:43 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-18 09:38:28 +0200
commit9fd7808f79fe48af9d9a4d47561abb9b8c66cbc3 (patch)
treea16d9aad588e70a34bdfe69fe4e709d3bc99226b /starmath
parent2caee0fac86165730b676727390dc74852f9663d (diff)
loplugin:useuniqueptr pass SmNodeList around by std::unique_ptr(2)
Change-Id: I53b7f39ddc150367bc5f9c4a7ee7049d59e9f485 Reviewed-on: https://gerrit.libreoffice.org/59231 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/cursor.hxx4
-rw-r--r--starmath/source/cursor.cxx24
2 files changed, 13 insertions, 15 deletions
diff --git a/starmath/inc/cursor.hxx b/starmath/inc/cursor.hxx
index 4c3e5b3eb0cd..b04b39748829 100644
--- a/starmath/inc/cursor.hxx
+++ b/starmath/inc/cursor.hxx
@@ -261,7 +261,7 @@ private:
void BuildGraph();
/** Insert new nodes in the tree after position */
- void InsertNodes(SmNodeList* pNewNodes);
+ void InsertNodes(std::unique_ptr<SmNodeList> pNewNodes);
/** tries to set position to a specific SmCaretPos
*
@@ -273,7 +273,7 @@ private:
void AnnotateSelection();
/** Clone list of nodes in a clipboard (creates a deep clone) */
- static SmNodeList* CloneList(SmClipboard &rClipboard);
+ static std::unique_ptr<SmNodeList> CloneList(SmClipboard &rClipboard);
/** Find an iterator pointing to the node in pLineList following rCaretPos
*
diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index 4afe12d2e445..cc0037f2ef85 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -291,9 +291,8 @@ void SmCursor::Delete(){
FinishEdit(std::move(pLineList), pLineParent, nLineOffset, PosAfterDelete);
}
-void SmCursor::InsertNodes(SmNodeList* pNewNodes){
+void SmCursor::InsertNodes(std::unique_ptr<SmNodeList> pNewNodes){
if(pNewNodes->empty()){
- delete pNewNodes;
return;
}
@@ -331,8 +330,7 @@ void SmCursor::InsertNodes(SmNodeList* pNewNodes){
PatchLineList(pLineList.get(), patchIt);
SmCaretPos PosAfterInsert = PatchLineList(pLineList.get(), it);
//Release list, we've taken the nodes
- delete pNewNodes;
- pNewNodes = nullptr;
+ pNewNodes.reset();
//Finish editing
FinishEdit(std::move(pLineList), pLineParent, nParentIndex, PosAfterInsert);
@@ -881,9 +879,9 @@ void SmCursor::InsertText(const OUString& aString)
pText->AdjustFontDesc();
pText->Prepare(mpDocShell->GetFormat(), *mpDocShell, 0);
- SmNodeList* pList = new SmNodeList;
+ std::unique_ptr<SmNodeList> pList(new SmNodeList);
pList->push_front(pText);
- InsertNodes(pList);
+ InsertNodes(std::move(pList));
EndEdit();
}
@@ -983,9 +981,9 @@ void SmCursor::InsertElement(SmFormulaElement element){
pNewNode->Prepare(mpDocShell->GetFormat(), *mpDocShell, 0);
//Insert new node
- SmNodeList* pList = new SmNodeList;
+ std::unique_ptr<SmNodeList> pList(new SmNodeList);
pList->push_front(pNewNode);
- InsertNodes(pList);
+ InsertNodes(std::move(pList));
EndEdit();
}
@@ -1010,9 +1008,9 @@ void SmCursor::InsertSpecial(const OUString& _aString)
pSpecial->Prepare(mpDocShell->GetFormat(), *mpDocShell, 0);
//Insert the node
- SmNodeList* pList = new SmNodeList;
+ std::unique_ptr<SmNodeList> pList(new SmNodeList);
pList->push_front(pSpecial);
- InsertNodes(pList);
+ InsertNodes(std::move(pList));
EndEdit();
}
@@ -1035,7 +1033,7 @@ void SmCursor::InsertCommandText(const OUString& aCommandText) {
Delete();
//Insert it
- InsertNodes(pLineList.release());
+ InsertNodes(std::move(pLineList));
EndEdit();
}
@@ -1087,9 +1085,9 @@ void SmCursor::Paste() {
EndEdit();
}
-SmNodeList* SmCursor::CloneList(SmClipboard &rClipboard){
+std::unique_ptr<SmNodeList> SmCursor::CloneList(SmClipboard &rClipboard){
SmCloningVisitor aCloneFactory;
- SmNodeList* pClones = new SmNodeList;
+ std::unique_ptr<SmNodeList> pClones(new SmNodeList);
for(auto &xNode : rClipboard){
SmNode *pClone = aCloneFactory.Clone(xNode.get());