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>
This commit is contained in:
Noel Grandin
2021-05-27 10:27:46 +02:00
parent 25a997c15d
commit 8611f6e259
314 changed files with 2512 additions and 3376 deletions

View File

@@ -505,6 +505,10 @@ bool RefCounting::VisitCXXDeleteExpr(const CXXDeleteExpr * cxxDeleteExpr)
compiler.getSourceManager().getSpellingLoc(cxxDeleteExpr->getBeginLoc()));
if (loplugin::isSamePathname(aFileName, SRCDIR "/cppuhelper/source/weak.cxx"))
return true;
if (loplugin::isSamePathname(aFileName, SRCDIR "/include/svx/svdobj.hxx"))
return true;
if (loplugin::isSamePathname(aFileName, SRCDIR "/svx/source/svdraw/svdobj.cxx"))
return true;
if (!cxxDeleteExpr->getArgument())
return true;
@@ -746,6 +750,15 @@ bool RefCounting::isCastingReference(const Expr* expr)
if (callMethod->getReturnType()->isReferenceType())
return false;
}
// Ignore
// WeakReference x;
// if (x.get.get())
// and similar stuff
if (auto memberCall2 = dyn_cast<CXXMemberCallExpr>(obj))
{
if (loplugin::TypeCheck(memberCall2->getImplicitObjectArgument()->getType()).Class("WeakReference"))
return false;
}
return true;
}