svx/source/unodraw/unoshape.cxx | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-)
New commits: commit b6fe3b13206eee0543ded37c3a1566add284e6da Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Thu Mar 3 11:50:43 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Mar 3 17:01:27 2022 +0100 no need to have two weak references to SdrObject in SvxShape Change-Id: I62d8e34e6896ae4aba951045d2e6ce1669c0ed23 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130913 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 1dc0ce4331a9..8ccfde1b8b12 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -115,13 +115,6 @@ struct SvxShapeImpl bool mbHasSdrObjectOwnership; bool mbDisposing; - /** CL, OD 2005-07-19 #i52126# - this is initially 0 and set when - * a SvxShape::Create() call is executed. It is then set to the created - * SdrObject so a multiple call to SvxShape::Create() with same SdrObject - * is prohibited. - */ - ::tools::WeakReference< SdrObject > mpCreatedObj; - // for xComponent ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> maDisposeListeners; svx::PropertyChangeNotifier maPropertyNotifier; @@ -385,7 +378,7 @@ void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ ) if ( !pNewObj ) return; - SdrObject* pCreatedObj = mpImpl->mpCreatedObj.get(); + SdrObject* pCreatedObj = mpSdrObjectWeakReference.get(); OSL_ENSURE( ( pCreatedObj == nullptr ) || ( pCreatedObj == pNewObj ), "SvxShape::Create: the same shape used for two different objects?! Strange ..." ); @@ -393,20 +386,14 @@ void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ ) if ( pCreatedObj == pNewObj ) return; - // Correct condition (#i52126#) - mpImpl->mpCreatedObj = pNewObj; - - if( HasSdrObject() ) + if( pCreatedObj ) { - EndListening( GetSdrObject()->getSdrModelFromSdrObject() ); + EndListening( pCreatedObj->getSdrModelFromSdrObject() ); } mpSdrObjectWeakReference.reset( pNewObj ); - if( HasSdrObject() ) - { - StartListening( GetSdrObject()->getSdrModelFromSdrObject() ); - } + StartListening( pNewObj->getSdrModelFromSdrObject() ); OSL_ENSURE( !mbIsMultiPropertyCall, "SvxShape::Create: hmm?" ); // this was previously set in impl_initFromSdrObject, but I think it was superfluous @@ -417,19 +404,19 @@ void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ ) ObtainSettingsFromPropertySet( *mpPropSet ); // save user call - SdrObjUserCall* pUser = GetSdrObject()->GetUserCall(); - GetSdrObject()->SetUserCall(nullptr); + SdrObjUserCall* pUser = pNewObj->GetUserCall(); + pNewObj->SetUserCall(nullptr); setPosition( maPosition ); setSize( maSize ); // restore user call after we set the initial size - GetSdrObject()->SetUserCall( pUser ); + pNewObj->SetUserCall( pUser ); // if this shape was already named, use this name if( !maShapeName.isEmpty() ) { - GetSdrObject()->SetName( maShapeName ); + pNewObj->SetName( maShapeName ); maShapeName.clear(); } }