sd/source/ui/view/sdview3.cxx |    3 ++-
 svx/source/svdraw/svdundo.cxx |    9 ++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

New commits:
commit ff436702b03aee7a4c7905ed30bf80d35b96f2db
Author:     Balazs Varga <[email protected]>
AuthorDate: Mon Dec 22 14:59:46 2025 +0100
Commit:     Balazs Varga <[email protected]>
CommitDate: Mon Dec 29 09:22:02 2025 +0100

    tdf#170027 - sd fix crash when undoing shape drag with Alt pressed
    
    Do not overwrite original shape during drag&drop with Alt,
    when we try to drag&drop the shape on the same shape,
    but create a new shape with new name, same as if we would drag&drop
    the object in general.
    
    cherry-pick from: 9f980e021ff1a7613003e5c93ec49a37c5ca3420
    
    Change-Id: I08b2197b3b9755455a165a566eb3452846c0f78e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196097
    Reviewed-by: Mike Kaganski <[email protected]>
    Reviewed-by: Balazs Varga <[email protected]>
    Tested-by: Jenkins
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196252
    Tested-by: allotropia jenkins <[email protected]>

diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx
index 4f7a52b0a9c3..d12362ebe8c0 100644
--- a/sd/source/ui/view/sdview3.cxx
+++ b/sd/source/ui/view/sdview3.cxx
@@ -732,7 +732,7 @@ bool View::InsertData( const TransferableDataHelper& 
rDataHelper,
                         SdrPageView*    pPV = nullptr;
                         SdrObject* pPickObj2 = PickObj(rPos, getHitTolLog(), 
pPV);
 
-                        if( ( mnAction & DND_ACTION_MOVE ) && pPickObj2 && 
pObj )
+                        if( ( mnAction & DND_ACTION_MOVE ) && pPickObj2 && 
pObj && pPickObj2->GetName() != pObj->GetName() )
                         {
                             // replace object
                             SdrPage* pWorkPage = GetSdrPageView()->GetPage();
@@ -772,6 +772,7 @@ bool View::InsertData( const TransferableDataHelper& 
rDataHelper,
                             mnAction = DND_ACTION_COPY;
                         }
                         else if( ( mnAction & DND_ACTION_LINK ) && pPickObj && 
pObj &&
+                            pPickObj->GetName() != pObj->GetName() &&
                             dynamic_cast< const SdrGrafObj *>( pPickObj ) ==  
nullptr &&
                                 dynamic_cast< const SdrOle2Obj *>( pPickObj ) 
==  nullptr )
                         {
diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx
index 7d98d21b7cb4..85e7b1466c1b 100644
--- a/svx/source/svdraw/svdundo.cxx
+++ b/svx/source/svdraw/svdundo.cxx
@@ -702,7 +702,7 @@ void SdrUndoRemoveObj::Undo()
     // For UNDOs in Calc/Writer it is necessary to adapt the anchor
     // position of the target object.
     Point aOwnerAnchorPos(0, 0);
-
+    assert(pObjList); // must never be null
     if (dynamic_cast< const SdrObjGroup* 
>(pObjList->getSdrObjectFromSdrObjList()) != nullptr)
     {
         aOwnerAnchorPos = 
pObjList->getSdrObjectFromSdrObjList()->GetAnchorPos();
@@ -725,6 +725,7 @@ void SdrUndoRemoveObj::Redo()
     {
         ImplUnmarkObject( mxObj.get() );
         E3DModifySceneSnapRectUpdater aUpdater(mxObj.get());
+        assert(pObjList); // must never be null
         pObjList->RemoveObject(mxObj->GetOrdNum());
     }
 
@@ -746,7 +747,7 @@ void SdrUndoInsertObj::Undo()
     if (mxObj->IsInserted())
     {
         ImplUnmarkObject( mxObj.get() );
-
+        assert(pObjList); // must never be null
         rtl::Reference<SdrObject> pChkObj= 
pObjList->RemoveObject(mxObj->GetOrdNum());
         DBG_ASSERT(pChkObj.get()==mxObj.get(),"UndoInsertObj: 
RemoveObjNum!=mxObj");
     }
@@ -761,7 +762,7 @@ void SdrUndoInsertObj::Redo()
         // which becomes a member of a group, because its cleared in method
         // <InsertObject(..)>. Needed for correct Redo in Writer. (#i45952#)
         Point aAnchorPos( 0, 0 );
-
+        assert(pObjList); // must never be null
         if (dynamic_cast<const 
SdrObjGroup*>(pObjList->getSdrObjectFromSdrObjList()) != nullptr)
         {
             aAnchorPos = mxObj->GetAnchorPos();
@@ -857,12 +858,14 @@ void SdrUndoReplaceObj::Undo()
     DBG_ASSERT(mxNewObj->IsInserted(),"SdrUndoReplaceObj::Undo(): New object 
is not inserted!");
 
     ImplUnmarkObject( mxNewObj.get() );
+    assert(pObjList); // must never be null
     pObjList->ReplaceObject(mxObj.get(), mxNewObj->GetOrdNum());
 }
 
 void SdrUndoReplaceObj::Redo()
 {
     ImplUnmarkObject( mxObj.get() );
+    assert(pObjList); // must never be null
     pObjList->ReplaceObject(mxNewObj.get(), mxObj->GetOrdNum());
 
     // Trigger PageChangeCall

Reply via email to