sd/source/ui/view/sdview3.cxx |    3 +--
 svx/source/svdraw/svdundo.cxx |   12 ++++--------
 2 files changed, 5 insertions(+), 10 deletions(-)

New commits:
commit eaaf3693cfb633777e924e2fea4222aa1ac22c8a
Author:     Balazs Varga <[email protected]>
AuthorDate: Wed Jan 7 08:29:26 2026 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Wed Jan 28 09:49:06 2026 +0100

    Related tdf#170027 - Crash when undoing shape drag with Alt pressed
    
    Partly revert and follow up of 0dc03683f9536123327963c170203addb8408930
    Since the shape names can be empty, better to not check the two shape
    names, otherwise the Alt drag will not work with those shapes. Since
    the alt draged shape is cloned, so a new shape was created, nothing else
    can be checked that the cloned and the original shape is the same or
    not. So just avoid crash at undo for the moment.
    
    Change-Id: I6cb86d776ddc9643919b9399bb2987b19d8bccf6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196655
    Tested-by: Jenkins
    Tested-by: Gabor Kelemen <[email protected]>
    Reviewed-by: Balazs Varga <[email protected]>
    (cherry picked from commit b10b28b6575b387ea4a7a0b91283690610158a2a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196831
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx
index 138219c05431..27f66c6a2f67 100644
--- a/sd/source/ui/view/sdview3.cxx
+++ b/sd/source/ui/view/sdview3.cxx
@@ -764,7 +764,7 @@ bool View::InsertData( const TransferableDataHelper& 
rDataHelper,
                         SdrPageView*    pPV = nullptr;
                         SdrObject* pPickObj2 = PickObj(rPos, getHitTolLog(), 
pPV);
 
-                        if( ( mnAction & DND_ACTION_MOVE ) && pPickObj2 && 
pObj && pPickObj2->GetName() != pObj->GetName() )
+                        if( ( mnAction & DND_ACTION_MOVE ) && pPickObj2 && 
pObj )
                         {
                             // replace object
                             SdrPage* pWorkPage = GetSdrPageView()->GetPage();
@@ -804,7 +804,6 @@ bool View::InsertData( const TransferableDataHelper& 
rDataHelper,
                             mnAction = DND_ACTION_COPY;
                         }
                         else if( ( mnAction & DND_ACTION_LINK ) && pPickObj2 
&& pObj &&
-                            pPickObj2->GetName() != pObj->GetName() &&
                             dynamic_cast< const SdrGrafObj *>( pPickObj2 ) ==  
nullptr &&
                                 dynamic_cast< const SdrOle2Obj *>( pPickObj2 ) 
==  nullptr )
                         {
diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx
index cc6de3fe1d5c..e64cb643b202 100644
--- a/svx/source/svdraw/svdundo.cxx
+++ b/svx/source/svdraw/svdundo.cxx
@@ -695,7 +695,7 @@ void SdrUndoRemoveObj::Undo()
     ImpShowPageOfThisObject();
 
     DBG_ASSERT(!mxObj->IsInserted(),"UndoRemoveObj: mxObj has already been 
inserted.");
-    if (mxObj->IsInserted())
+    if (mxObj->IsInserted() || !pObjList)
         return;
 
     // #i11426#
@@ -703,7 +703,6 @@ void SdrUndoRemoveObj::Undo()
     // 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();
@@ -722,11 +721,10 @@ void SdrUndoRemoveObj::Undo()
 void SdrUndoRemoveObj::Redo()
 {
     DBG_ASSERT(mxObj->IsInserted(),"RedoRemoveObj: mxObj is not inserted.");
-    if (mxObj->IsInserted())
+    if (mxObj->IsInserted() && pObjList)
     {
         ImplUnmarkObject( mxObj.get() );
         E3DModifySceneSnapRectUpdater aUpdater(mxObj.get());
-        assert(pObjList); // must never be null
         pObjList->RemoveObject(mxObj->GetOrdNum());
     }
 
@@ -745,11 +743,10 @@ void SdrUndoInsertObj::Undo()
     ImpShowPageOfThisObject();
 
     DBG_ASSERT(mxObj->IsInserted(),"UndoInsertObj: mxObj is not inserted.");
-    if (mxObj->IsInserted())
+    if (mxObj->IsInserted() && pObjList)
     {
         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");
     }
@@ -758,14 +755,13 @@ void SdrUndoInsertObj::Undo()
 void SdrUndoInsertObj::Redo()
 {
     DBG_ASSERT(!mxObj->IsInserted(),"RedoInsertObj: mxObj is already 
inserted");
-    if (!mxObj->IsInserted())
+    if (!mxObj->IsInserted() && pObjList)
     {
         // Restore anchor position of an object,
         // 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();

Reply via email to