sd/source/ui/view/sdview3.cxx | 3 +-- svx/source/svdraw/svdundo.cxx | 12 ++++-------- 2 files changed, 5 insertions(+), 10 deletions(-)
New commits: commit bfd29c67d3adcd3ddf8e81caaa3af20f92906f4b Author: Balazs Varga <[email protected]> AuthorDate: Wed Jan 7 08:29:26 2026 +0100 Commit: Balazs Varga <[email protected]> CommitDate: Fri Jan 9 18:08: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. cherry-pick from: b10b28b6575b387ea4a7a0b91283690610158a2a 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]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196783 Tested-by: Balazs Varga <[email protected]> diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx index d12362ebe8c0..4f7a52b0a9c3 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 && pPickObj2->GetName() != pObj->GetName() ) + if( ( mnAction & DND_ACTION_MOVE ) && pPickObj2 && pObj ) { // replace object SdrPage* pWorkPage = GetSdrPageView()->GetPage(); @@ -772,7 +772,6 @@ 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 85e7b1466c1b..2a16b24a1b8b 100644 --- a/svx/source/svdraw/svdundo.cxx +++ b/svx/source/svdraw/svdundo.cxx @@ -695,14 +695,13 @@ void SdrUndoRemoveObj::Undo() ImpShowPageOfThisObject(); DBG_ASSERT(!mxObj->IsInserted(),"UndoRemoveObj: mxObj has already been inserted."); - if (mxObj->IsInserted()) + if (mxObj->IsInserted() || !pObjList) return; // #i11426# // 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(); @@ -721,11 +720,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()); } @@ -744,10 +742,9 @@ 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"); } @@ -756,13 +753,12 @@ 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();
