diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-03-03 11:50:43 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-03-03 17:01:27 +0100 |
commit | b6fe3b13206eee0543ded37c3a1566add284e6da (patch) | |
tree | bc50922783c9a8411a6277a60acb326dd7fcf00a /svx | |
parent | 94bdee6bf24965fab957c73a2c38e34c115a030e (diff) |
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.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/unodraw/unoshape.cxx | 29 |
1 files changed, 8 insertions, 21 deletions
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(); } } |