summaryrefslogtreecommitdiff
path: root/include/unotools/weakref.hxx
AgeCommit message (Collapse)Author
2022-12-03Clarify the use of untools::WeakReferenceStephan Bergmann
...which had been introduced in 78040af9acea0ab681aa54ff23844b647bc9b4f3 "loplugin:refcounting in sc" as a variation on css::uno::WeakReference from include/cppuhelper/weakref.hxx, but without giving much of a rationale. And, at least for --with-latest-c++ builds using a capable C++20 compiler, ensure that the given interface_type is such that the static_cast and dynamic_cast in the implementation of unotools::WeakReference::get are actually sound: If interface_type could be a UNO interface type, that would imply that the xInterface obtained from the underlying WeakReferenceHelper::get() could be a proxy from the C++ UNO bridge, which could (a) be a proxy for only a subtype of interface_type (e.g., just for XInterface), so that the static_cast would be broken, and (b) be a proxy for which the vtable's RTTI slot is not set up (see e.g. the ENABLE_RUNTIME_OPTIMIZATIONS code in bridges::cpp_uno::shared::VtableFactory::initializeBlock in bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx), so that the dynamic_cast could crash. (These issues can even happen when the given interface_type is a C++ implementation class type, but the given object has been bridged over some C++ to C++ UNO ("purpose") bridge, but lets leave it at that...) This required adding some cppu::detail::isUnoInterfaceType predicate to the include files generated by cppumaker, which can be useful in other places too. (For the call to isUnoInterfaceType in the requires-clause of unotools::WeakReference<interface_type>::get to give the correct answer, it is important that interface_type is a complete type---i.e., the corresponding codemaker-generated .hpp having been included if interface_type actually were a UNO include type. But that is already nicely required by the call to std::is_convertible_v in the implementation of that function, anyway.) Change-Id: Ia5efd70085d2d6d45fa0995d00dc8def564bbe5f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143601 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-04address review comments in unotools::WeakReferenceNoel Grandin
from commit 4e0856fa11674e386c9b84dd40a702c83450166f Change-Id: I0dbd6a115b36be8030120a8006959e611f637f07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142266 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-11-04tdf#54857 use more static_cast in WeakReference::getNoel Grandin
which shaves 3% off the load time here. Change-Id: I514dedc765ad12da2ad08e115c1ebf86c653c433 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142237 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-29ref-count SdrObjectNoel Grandin
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>
2022-02-28address review comments for "Add XWeak constructor..."Noel Grandin
for commit 27352b81638f2f1e792ab48ec532eaacf6f61718 (origin/master, origin/HEAD) Author: Noel Grandin <noel.grandin@collabora.co.uk> Date: Mon Feb 21 16:00:52 2022 +0200 Add XWeak constructor and operator= to uno::WeakReference I accidentally created a new gerrit change for this, and thus managed to miss sorting out various review comments. (*) Fix version number in gcc3.map (*) Narrow the interface (i.e. assume non-null parameter) in WeakReferenceHelper (*) Remove cargo-cult catch and OSL_ASSERT in WeakReferenceHelper (*) Remove accidental indentation Change-Id: I8d1b22dd42216e9293959032d92df65405fb054c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130349 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-02-22Add XWeak constructor and operator= to uno::WeakReferenceNoel Grandin
which is faster since we can skip the UNO_QUERY. Change-Id: Id95ad9f3568213e974bd13659d92d4ea94dbfbd6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130282 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-04-09Recheck include/ with IWYUGabor Kelemen
See tdf#42949 for motivation Change-Id: Ifc253bf800bb1468b5774663a93f4fb30bec81d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113657 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2021-02-21loplugin:refcounting in scNoel
Change-Id: Id0ba24985aab36b931fa74b266dc5bf0bef62bb7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111273 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>