starmath: Represent ownership by std::unique_ptr

Change-Id: I7ce39cbdc0199d3508e7d16d1ce0b78f8d8ca620
Reviewed-on: https://gerrit.libreoffice.org/19230
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
Takeshi Abe
2015-10-07 23:21:00 +09:00
committed by Noel Grandin
parent bbfc031333
commit ce924d97aa
2 changed files with 4 additions and 6 deletions

View File

@@ -13,6 +13,7 @@
#include "caret.hxx" #include "caret.hxx"
#include <list> #include <list>
#include <memory>
/** Factor to multiple the squared horizontal distance with /** Factor to multiple the squared horizontal distance with
* Used for Up and Down movement. * Used for Up and Down movement.
@@ -82,7 +83,6 @@ public:
, mpPosition(nullptr) , mpPosition(nullptr)
, mpTree(tree) , mpTree(tree)
, mpDocShell(pShell) , mpDocShell(pShell)
, mpGraph(nullptr)
, mpClipboard(nullptr) , mpClipboard(nullptr)
, mnEditSections(0) , mnEditSections(0)
, mbIsEnabledSetModifiedSmDocShell(false) , mbIsEnabledSetModifiedSmDocShell(false)
@@ -94,8 +94,6 @@ public:
~SmCursor() ~SmCursor()
{ {
SetClipboard(); SetClipboard();
delete mpGraph;
mpGraph = nullptr;
} }
/** Get position */ /** Get position */
@@ -230,7 +228,7 @@ private:
/** Owner of the formula tree */ /** Owner of the formula tree */
SmDocShell* mpDocShell; SmDocShell* mpDocShell;
/** Graph over caret position in the current tree */ /** Graph over caret position in the current tree */
SmCaretPosGraph* mpGraph; std::unique_ptr<SmCaretPosGraph> mpGraph;
/** Clipboard holder */ /** Clipboard holder */
SmNodeList* mpClipboard; SmNodeList* mpClipboard;

View File

@@ -114,14 +114,14 @@ void SmCursor::BuildGraph(){
_anchor = mpAnchor->CaretPos; _anchor = mpAnchor->CaretPos;
if(mpPosition) if(mpPosition)
_position = mpPosition->CaretPos; _position = mpPosition->CaretPos;
delete mpGraph; mpGraph.reset();
//Reset anchor and position as they point into an old graph //Reset anchor and position as they point into an old graph
mpAnchor = nullptr; mpAnchor = nullptr;
mpPosition = nullptr; mpPosition = nullptr;
} }
//Build the new graph //Build the new graph
mpGraph = SmCaretPosGraphBuildingVisitor(mpTree).takeGraph(); mpGraph.reset(SmCaretPosGraphBuildingVisitor(mpTree).takeGraph());
//Restore anchor and position pointers //Restore anchor and position pointers
if(_anchor.IsValid() || _position.IsValid()){ if(_anchor.IsValid() || _position.IsValid()){