Kaydet (Commit) ce924d97 authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Noel Grandin

starmath: Represent ownership by std::unique_ptr

Change-Id: I7ce39cbdc0199d3508e7d16d1ce0b78f8d8ca620
Reviewed-on: https://gerrit.libreoffice.org/19230Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst bbfc0313
......@@ -13,6 +13,7 @@
#include "caret.hxx"
#include <list>
#include <memory>
/** Factor to multiple the squared horizontal distance with
* Used for Up and Down movement.
......@@ -82,7 +83,6 @@ public:
, mpPosition(nullptr)
, mpTree(tree)
, mpDocShell(pShell)
, mpGraph(nullptr)
, mpClipboard(nullptr)
, mnEditSections(0)
, mbIsEnabledSetModifiedSmDocShell(false)
......@@ -94,8 +94,6 @@ public:
~SmCursor()
{
SetClipboard();
delete mpGraph;
mpGraph = nullptr;
}
/** Get position */
......@@ -230,7 +228,7 @@ private:
/** Owner of the formula tree */
SmDocShell* mpDocShell;
/** Graph over caret position in the current tree */
SmCaretPosGraph* mpGraph;
std::unique_ptr<SmCaretPosGraph> mpGraph;
/** Clipboard holder */
SmNodeList* mpClipboard;
......
......@@ -114,14 +114,14 @@ void SmCursor::BuildGraph(){
_anchor = mpAnchor->CaretPos;
if(mpPosition)
_position = mpPosition->CaretPos;
delete mpGraph;
mpGraph.reset();
//Reset anchor and position as they point into an old graph
mpAnchor = nullptr;
mpPosition = nullptr;
}
//Build the new graph
mpGraph = SmCaretPosGraphBuildingVisitor(mpTree).takeGraph();
mpGraph.reset(SmCaretPosGraphBuildingVisitor(mpTree).takeGraph());
//Restore anchor and position pointers
if(_anchor.IsValid() || _position.IsValid()){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment