diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-27 10:27:46 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-08-29 13:44:02 +0200 |
commit | 8611f6e259b807b4f19c8dc0eab86ca648891ce3 (patch) | |
tree | fa2b0e463aafb51df754768f916ca9104969a557 /sd/source/ui/unoidl | |
parent | 25a997c15d39fb30676a375df8ea4ce1ed2e1acd (diff) |
ref-count SdrObject
Which means we can get rid of the majestic hack of ScCaptionPtr
Previously, SdrObject was manually managed, and the ownership
passed around in very complicated fashion.
Notes:
(*) SvxShape has a strong reference to SdrObject, where
previously it had a weak reference. It is now strong
since otherwise the SdrObject will go away very eagerly.
(*) SdrObject still has a weak reference to SvxShape
(*) In the existing places that an SdrObject is being
deleted, we now just clear the reference
(*) instead of SwVirtFlyDrawObj removing itself from the
page that contains inside it's destructor, make the call site
do the removing from the page.
(*) Needed to take the SolarMutex in UndoManagerHelper_Impl::impl_clear
because this can be called from UNO (e.g. sfx2_complex JUnit test)
and the SdrObjects need the SolarMutex when destructing.
(*) handle a tricky situation with SwDrawVirtObj in the SwDrawModel
destructor because the existing code wants mpDrawObj in
SwAnchoredObject to be sometimes owning, sometimes not, which
results in a cycle with the new code.
Change-Id: I4d79df1660e386388e5d51030653755bca02a163
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138837
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd/source/ui/unoidl')
-rw-r--r-- | sd/source/ui/unoidl/unoobj.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unopage.cxx | 9 |
2 files changed, 4 insertions, 9 deletions
diff --git a/sd/source/ui/unoidl/unoobj.cxx b/sd/source/ui/unoidl/unoobj.cxx index 85a3045d5000..b90636070135 100644 --- a/sd/source/ui/unoidl/unoobj.cxx +++ b/sd/source/ui/unoidl/unoobj.cxx @@ -479,10 +479,6 @@ void SAL_CALL SdXShape::setPropertyValue( const OUString& aPropertyName, const c if(!pGroup->GetSubList()->GetObjCount()) { pPage->NbcRemoveObject(pGroup->GetOrdNum()); - - // always use SdrObject::Free(...) for SdrObjects (!) - SdrObject* pTemp(pGroup); - SdrObject::Free(pTemp); } } } diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index c0536daab015..4831b29bb53d 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -388,7 +388,7 @@ void SdGenericDrawPage::UpdateModel() } // this is called whenever a SdrObject must be created for an empty api shape wrapper -SdrObject * SdGenericDrawPage::CreateSdrObject_( const Reference< drawing::XShape >& xShape ) +rtl::Reference<SdrObject> SdGenericDrawPage::CreateSdrObject_( const Reference< drawing::XShape >& xShape ) { if( nullptr == SvxFmDrawPage::mpPage || !xShape.is() ) return nullptr; @@ -397,8 +397,7 @@ SdrObject * SdGenericDrawPage::CreateSdrObject_( const Reference< drawing::XShap static const OUStringLiteral aPrefix( u"com.sun.star.presentation." ); if( !aType.startsWith( aPrefix ) ) { - SdrObject* pObj = SvxFmDrawPage::CreateSdrObject_( xShape ); - return pObj; + return SvxFmDrawPage::CreateSdrObject_( xShape ); } aType = aType.copy( aPrefix.getLength() ); @@ -485,7 +484,7 @@ SdrObject * SdGenericDrawPage::CreateSdrObject_( const Reference< drawing::XShap const awt::Size aSize( aRect.GetWidth(), aRect.GetHeight() ); xShape->setSize( aSize ); - SdrObject *pPresObj = nullptr; + rtl::Reference<SdrObject> pPresObj; if( (eObjKind == PresObjKind::Table) || (eObjKind == PresObjKind::Media) ) { pPresObj = SvxFmDrawPage::CreateSdrObject_( xShape ); @@ -493,7 +492,7 @@ SdrObject * SdGenericDrawPage::CreateSdrObject_( const Reference< drawing::XShap { SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage())); pPresObj->NbcSetStyleSheet(rDoc.GetDefaultStyleSheet(), true); - GetPage()->InsertPresObj( pPresObj, eObjKind ); + GetPage()->InsertPresObj( pPresObj.get(), eObjKind ); } } else |