diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-09-08 21:14:26 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-09-09 09:18:19 +0200 |
commit | fe42f7c23b8816a930a204c0d5f104dee207b345 (patch) | |
tree | 6f3b6d72753d9ac633257b902a74e7d5dbefe53c /svx/source | |
parent | 1ff238e5703507ad9d60810d20817052e5b43390 (diff) |
cid#1556149 disentangle this undo code a little
Change-Id: Id4bf243276f16a7e840df0cacf2ca4151b49ca46
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173052
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/svdraw/svddrgv.cxx | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/svx/source/svdraw/svddrgv.cxx b/svx/source/svdraw/svddrgv.cxx index a8584437bb54..acdb5292d72a 100644 --- a/svx/source/svdraw/svddrgv.cxx +++ b/svx/source/svdraw/svddrgv.cxx @@ -44,7 +44,6 @@ using namespace sdr; SdrDragView::SdrDragView(SdrModel& rSdrModel, OutputDevice* pOut) : SdrExchangeView(rSdrModel, pOut) , mpDragHdl(nullptr) - , mpInsPointUndo(nullptr) , meDragHdl(SdrHdlKind::Move) , mnDragThresholdPixels(6) , mbFramDrag(false) @@ -549,7 +548,7 @@ bool SdrDragView::EndDragObj(bool bCopy) if (IsInsertGluePoint() && bUndo) { BegUndo(maInsPointUndoStr); - AddUndo(std::unique_ptr<SdrUndoAction>(mpInsPointUndo)); + AddUndo(std::move(mpInsPointUndo)); } bRet = mpCurrentSdrDragMethod->EndSdrDrag(bCopy); @@ -574,7 +573,7 @@ bool SdrDragView::EndDragObj(bool bCopy) if( bUndo ) { BegUndo(maInsPointUndoStr); - AddUndo(std::unique_ptr<SdrUndoAction>(mpInsPointUndo)); + AddUndo(std::move(mpInsPointUndo)); EndUndo(); } } @@ -614,8 +613,7 @@ void SdrDragView::BrkDragObj() if (mbInsPolyPoint) { mpInsPointUndo->Undo(); // delete inserted point again - delete mpInsPointUndo; - mpInsPointUndo=nullptr; + mpInsPointUndo.reset(); SetMarkHandles(nullptr); mbInsPolyPoint=false; } @@ -623,8 +621,7 @@ void SdrDragView::BrkDragObj() if (IsInsertGluePoint()) { mpInsPointUndo->Undo(); // delete inserted gluepoint again - delete mpInsPointUndo; - mpInsPointUndo=nullptr; + mpInsPointUndo.reset(); SetInsertGluePoint(false); } @@ -644,7 +641,7 @@ bool SdrDragView::ImpBegInsObjPoint(bool bIdxZwang, const Point& rPnt, bool bNew if(auto pMarkedPath = dynamic_cast<SdrPathObj*>( mpMarkedObj)) { BrkAction(); - mpInsPointUndo = dynamic_cast<SdrUndoGeoObj*>(GetModel().GetSdrUndoFactory().CreateUndoGeoObject(*mpMarkedObj).release()); + mpInsPointUndo = GetModel().GetSdrUndoFactory().CreateUndoGeoObject(*mpMarkedObj); DBG_ASSERT( mpInsPointUndo, "svx::SdrDragView::BegInsObjPoint(), could not create correct undo object!" ); OUString aStr(SvxResId(STR_DragInsertPoint)); @@ -687,8 +684,7 @@ bool SdrDragView::ImpBegInsObjPoint(bool bIdxZwang, const Point& rPnt, bool bNew } else { - delete mpInsPointUndo; - mpInsPointUndo = nullptr; + mpInsPointUndo.reset(); } } @@ -743,7 +739,7 @@ bool SdrDragView::BegInsGluePoint(const Point& rPnt) { BrkAction(); UnmarkAllGluePoints(); - mpInsPointUndo = dynamic_cast<SdrUndoGeoObj*>(GetModel().GetSdrUndoFactory().CreateUndoGeoObject(*pObj).release()); + mpInsPointUndo = GetModel().GetSdrUndoFactory().CreateUndoGeoObject(*pObj); DBG_ASSERT( mpInsPointUndo, "svx::SdrDragView::BegInsObjPoint(), could not create correct undo object!" ); OUString aStr(SvxResId(STR_DragInsertGluePoint)); @@ -774,8 +770,7 @@ bool SdrDragView::BegInsGluePoint(const Point& rPnt) else { SetInsertGluePoint(false); - delete mpInsPointUndo; - mpInsPointUndo=nullptr; + mpInsPointUndo.reset(); } } else @@ -787,8 +782,7 @@ bool SdrDragView::BegInsGluePoint(const Point& rPnt) { // no gluepoints possible for this object (e. g. Edge) SetInsertGluePoint(false); - delete mpInsPointUndo; - mpInsPointUndo=nullptr; + mpInsPointUndo.reset(); } } |