include/svx/svddrgv.hxx       |    2 +-
 svx/source/svdraw/svddrgv.cxx |   27 ++++++++++-----------------
 2 files changed, 11 insertions(+), 18 deletions(-)

New commits:
commit 4768ee57da0f4e2004c1bc60b19cae49eafe0497
Author:     Caolán McNamara <[email protected]>
AuthorDate: Sun Sep 8 21:19:01 2024 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Mon Sep 9 09:18:31 2024 +0200

    can only be mbInsPolyPoint or IsInsertGluePoint()
    
    Change-Id: I5378895e936cfcc524f769754148f96cfbd8685d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173053
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins

diff --git a/svx/source/svdraw/svddrgv.cxx b/svx/source/svdraw/svddrgv.cxx
index acdb5292d72a..82be2f067c80 100644
--- a/svx/source/svdraw/svddrgv.cxx
+++ b/svx/source/svdraw/svddrgv.cxx
@@ -617,8 +617,7 @@ void SdrDragView::BrkDragObj()
         SetMarkHandles(nullptr);
         mbInsPolyPoint=false;
     }
-
-    if (IsInsertGluePoint())
+    else if (IsInsertGluePoint())
     {
         mpInsPointUndo->Undo(); // delete inserted gluepoint again
         mpInsPointUndo.reset();
commit fe42f7c23b8816a930a204c0d5f104dee207b345
Author:     Caolán McNamara <[email protected]>
AuthorDate: Sun Sep 8 21:14:26 2024 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Mon Sep 9 09:18:19 2024 +0200

    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 <[email protected]>
    Tested-by: Jenkins

diff --git a/include/svx/svddrgv.hxx b/include/svx/svddrgv.hxx
index ee91134bdc5f..0fb939bec6fb 100644
--- a/include/svx/svddrgv.hxx
+++ b/include/svx/svddrgv.hxx
@@ -40,7 +40,7 @@ class SVXCORE_DLLPUBLIC SdrDragView : public SdrExchangeView
 protected:
     SdrHdl*                     mpDragHdl;
     std::unique_ptr<SdrDragMethod> mpCurrentSdrDragMethod;
-    SdrUndoGeoObj*              mpInsPointUndo;
+    std::unique_ptr<SdrUndoAction> mpInsPointUndo;
     tools::Rectangle            maDragLimit;
     OUString                    maInsPointUndoStr;
     SdrHdlKind                  meDragHdl;
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();
         }
     }
 

Reply via email to