From fe42f7c23b8816a930a204c0d5f104dee207b345 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 8 Sep 2024 21:14:26 +0100 Subject: cid#1556149 disentangle this undo code a little MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id4bf243276f16a7e840df0cacf2ca4151b49ca46 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173052 Reviewed-by: Caolán McNamara Tested-by: Jenkins --- svx/source/svdraw/svddrgv.cxx | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'svx/source') 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(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(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( mpMarkedObj)) { BrkAction(); - mpInsPointUndo = dynamic_cast(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(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(); } } -- cgit