move vcl::DeleteOnDeinit to tools

so we can fix a shutdown use-after-free in sot.

Change-Id: I32f83bd94627d72d7bee7ea2ebd6ab77a7f78435
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175335
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2024-10-21 14:36:51 +02:00
parent 76319347a8
commit 19bc8856c4
38 changed files with 100 additions and 97 deletions

View file

@ -113,7 +113,7 @@ public:
if (!pDefinition) { // maybe no definition if it's a pointer/reference
return std::make_pair(false, std::vector<FieldDecl const*>());
}
if ( type.Class("DeleteOnDeinit").Namespace("vcl").GlobalNamespace()
if ( type.Class("DeleteOnDeinit").Namespace("tools").GlobalNamespace()
|| type.Class("weak_ptr").StdNamespace() // not owning
|| type.Class("ImplWallpaper").GlobalNamespace() // very odd static instance here
|| type.Class("Application").GlobalNamespace() // numerous odd subclasses in vclmain::createApplication()

View file

@ -337,7 +337,7 @@ bool containsSalhelperReferenceObjectSubclass(const clang::Type* pType0) {
if (dc.Class("Reference").Namespace("rtl").GlobalNamespace()
|| (dc.Class("OStoreHandle").AnonymousNamespace().Namespace("store")
.GlobalNamespace())
|| (dc.Class("DeleteRtlReferenceOnDeinit").Namespace("vcl")
|| (dc.Class("DeleteRtlReferenceOnDeinit").Namespace("tools")
.GlobalNamespace()))
{
return false;

View file

@ -4505,7 +4505,7 @@ sal_Int32 OSQLParser::s_nRefCount = 0;
// ::osl::Mutex OSQLParser::s_aMutex;
OSQLScanner* OSQLParser::s_pScanner = nullptr;
OSQLParseNodesGarbageCollector* OSQLParser::s_pGarbageCollector = nullptr;
vcl::DeleteOnDeinit<css::uno::Reference< css::i18n::XLocaleData4>> OSQLParser::s_xLocaleData(vcl::DeleteOnDeinitFlag::Empty);
tools::DeleteOnDeinit<css::uno::Reference< css::i18n::XLocaleData4>> OSQLParser::s_xLocaleData(tools::DeleteOnDeinitFlag::Empty);
void setParser(OSQLParser* _pParser)
{

View file

@ -9,7 +9,7 @@
#include "lokclipboard.hxx"
#include <unordered_map>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <vcl/svapp.hxx>
#include <sfx2/lokhelper.hxx>
#include <sal/log.hxx>
@ -20,7 +20,7 @@ using namespace css;
using namespace css::uno;
/* static */ osl::Mutex LOKClipboardFactory::gMutex;
static vcl::DeleteOnDeinit<std::unordered_map<int, rtl::Reference<LOKClipboard>>> gClipboards{};
static tools::DeleteOnDeinit<std::unordered_map<int, rtl::Reference<LOKClipboard>>> gClipboards{};
rtl::Reference<LOKClipboard> LOKClipboardFactory::getClipboardForCurView()
{

View file

@ -30,7 +30,7 @@
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <vcl/timer.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <vcl/dibtools.hxx>
#include <vcl/skia/SkiaHelper.hxx>
#include <mutex>
@ -383,7 +383,7 @@ VDevBuffer& getVDevBuffer()
// secure global instance with Vcl's safe destroyer of external (seen by
// library base) stuff, the remembered VDevs need to be deleted before
// Vcl's deinit
static vcl::DeleteOnDeinit<VDevBuffer> aVDevBuffer{};
static tools::DeleteOnDeinit<VDevBuffer> aVDevBuffer{};
return *aVDevBuffer.get();
}

View file

@ -522,7 +522,7 @@ void VclMetafileProcessor2D::popList()
}
// init static break iterator
vcl::DeleteOnDeinit<uno::Reference<css::i18n::XBreakIterator>>
tools::DeleteOnDeinit<uno::Reference<css::i18n::XBreakIterator>>
VclMetafileProcessor2D::mxBreakIterator;
VclMetafileProcessor2D::VclMetafileProcessor2D(const geometry::ViewInformation2D& rViewInformation,

View file

@ -25,7 +25,7 @@
#include <com/sun/star/i18n/XBreakIterator.hpp>
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <vcl/pdfextoutdevdata.hxx> // vcl::PDFExtOutDevData support
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
class GDIMetaFile;
namespace tools
@ -176,7 +176,7 @@ private:
constructed VclMetafileProcessor2D. It's still incarnated on demand,
but exists for OOo runtime now by purpose.
*/
static vcl::DeleteOnDeinit<css::uno::Reference<css::i18n::XBreakIterator>> mxBreakIterator;
static tools::DeleteOnDeinit<css::uno::Reference<css::i18n::XBreakIterator>> mxBreakIterator;
/* vcl::PDFExtOutDevData support
For the first step, some extra actions at vcl::PDFExtOutDevData need to

View file

@ -67,7 +67,7 @@
#include <rtl/strbuf.hxx>
#include <sal/log.hxx>
#include <vcl/help.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <vcl/transfer.hxx>
#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
#include <com/sun/star/frame/Desktop.hpp>
@ -1714,7 +1714,7 @@ rtl::Reference<SfxItemPool> EditEngine::CreatePool()
SfxItemPool& EditEngine::GetGlobalItemPool()
{
static vcl::DeleteOnDeinit<rtl::Reference<SfxItemPool>> pGlobalPool(CreatePool());
static tools::DeleteOnDeinit<rtl::Reference<SfxItemPool>> pGlobalPool(CreatePool());
return **pGlobalPool.get();
}

View file

@ -65,7 +65,7 @@
#include <editeng/forbiddencharacterstable.hxx>
#include <editeng/justifyitem.hxx>
#include <tools/mapunit.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <svl/itempool.hxx>
#include <editeng/editids.hrc>
@ -78,7 +78,7 @@ EditDLL& EditDLL::Get()
Previously this data was function-static, but then data in i18npool would
be torn down before the destructor here ran, causing a crash.
*/
static vcl::DeleteOnDeinit< EditDLL > gaEditDll;
static tools::DeleteOnDeinit< EditDLL > gaEditDll;
return *gaEditDll.get();
}

View file

@ -25,7 +25,7 @@
#include <connectivity/dbtoolsdllapi.hxx>
#include <connectivity/sqlerror.hxx>
#include <comphelper/singletonref.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <map>
#include <memory>
@ -140,7 +140,7 @@ namespace connectivity
sal_Int32 m_nDateFormatKey;
css::uno::Reference< css::uno::XComponentContext > m_xContext;
css::uno::Reference< css::i18n::XCharacterClassification> m_xCharClass;
static vcl::DeleteOnDeinit<css::uno::Reference< css::i18n::XLocaleData4>> s_xLocaleData;
static tools::DeleteOnDeinit<css::uno::Reference< css::i18n::XLocaleData4>> s_xLocaleData;
// convert a string into double trim it to scale of _nscale and then transform it back to string
OUString stringToDouble(const OUString& _rValue,sal_Int16 _nScale);

View file

@ -19,18 +19,18 @@
#pragma once
#include <vcl/dllapi.h>
#include <tools/toolsdllapi.h>
#include <com/sun/star/lang/XComponent.hpp>
#include <rtl/ref.hxx>
#include <optional>
namespace vcl
namespace tools
{
/*
You may not access vcl objects after DeInitVCL has been called this includes their destruction
therefore disallowing the existence of static vcl object like e.g. a static BitmapEx
You may not access some objects after DeInitVCL has been called this includes their destruction
therefore disallowing the existence of static object like e.g. a static BitmapEx
To work around this use DeleteOnDeinit<BitmapEx> which will allow you to have a static object container,
that will have its contents destroyed on DeinitVCL. The single drawback is that you need to check on the
container object whether it still contains content before actually accessing it.
@ -46,17 +46,17 @@ namespace vcl
SomeWindow::Paint()
{
static vcl::DeleteOnDeinit< BitmapEx > aBmp( ... );
static tools::DeleteOnDeinit< BitmapEx > aBmp( ... );
if( aBmp.get() ) // check whether DeInitVCL has been called already
DrawBitmapEx( Point( 10, 10 ), *aBmp );
}
*/
class VCL_DLLPUBLIC DeleteOnDeinitBase
class TOOLS_DLLPUBLIC DeleteOnDeinitBase
{
public:
static void SAL_DLLPRIVATE ImplDeleteOnDeInit();
static void ImplDeleteOnDeInit();
virtual ~DeleteOnDeinitBase();
protected:
static void addDeinitContainer( DeleteOnDeinitBase* i_pContainer );
@ -109,7 +109,7 @@ namespace vcl
\<do something with xFactory>
*/
template <typename I>
class DeleteUnoReferenceOnDeinit final : public vcl::DeleteOnDeinitBase
class DeleteUnoReferenceOnDeinit final : public tools::DeleteOnDeinitBase
{
css::uno::Reference<I> m_xI;
virtual void doCleanup() override { set(nullptr); }
@ -144,7 +144,7 @@ namespace vcl
\<do something with xFactory>
*/
template <typename I>
class DeleteRtlReferenceOnDeinit final : public vcl::DeleteOnDeinitBase
class DeleteRtlReferenceOnDeinit final : public tools::DeleteOnDeinitBase
{
rtl::Reference<I> m_xI;
virtual void doCleanup() override { set(nullptr); }

View file

@ -67,7 +67,7 @@ public:
void SetCacheGlyphsWhenDoingFallbackFonts(bool bOK);
static SalLayoutGlyphsCache* self();
SalLayoutGlyphsCache(int size) // needs to be public for vcl::DeleteOnDeinit
SalLayoutGlyphsCache(int size) // needs to be public for tools::DeleteOnDeinit
: mCachedGlyphs(size)
{
}

View file

@ -24,7 +24,7 @@
#include <sfx2/dispatch.hxx>
#include <vcl/help.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <vcl/ptrstyle.hxx>
#include <vcl/svapp.hxx>
@ -88,8 +88,16 @@ constexpr OUString aBigPlaceHolders[] =
static BitmapEx& getButtonImage( int index, bool large )
{
static vcl::DeleteOnDeinit< BitmapEx > gSmallButtonImages[SAL_N_ELEMENTS(aSmallPlaceHolders)] = { vcl::DeleteOnDeinitFlag::Empty, vcl::DeleteOnDeinitFlag::Empty, vcl::DeleteOnDeinitFlag::Empty, vcl::DeleteOnDeinitFlag::Empty, vcl::DeleteOnDeinitFlag::Empty, vcl::DeleteOnDeinitFlag::Empty, vcl::DeleteOnDeinitFlag::Empty, vcl::DeleteOnDeinitFlag::Empty };
static vcl::DeleteOnDeinit< BitmapEx > gLargeButtonImages[SAL_N_ELEMENTS(aBigPlaceHolders)] = { vcl::DeleteOnDeinitFlag::Empty, vcl::DeleteOnDeinitFlag::Empty, vcl::DeleteOnDeinitFlag::Empty, vcl::DeleteOnDeinitFlag::Empty, vcl::DeleteOnDeinitFlag::Empty, vcl::DeleteOnDeinitFlag::Empty, vcl::DeleteOnDeinitFlag::Empty, vcl::DeleteOnDeinitFlag::Empty };
static ::tools::DeleteOnDeinit< BitmapEx > gSmallButtonImages[SAL_N_ELEMENTS(aSmallPlaceHolders)] = {
::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty,
::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty,
::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty,
::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty };
static ::tools::DeleteOnDeinit< BitmapEx > gLargeButtonImages[SAL_N_ELEMENTS(aBigPlaceHolders)] = {
::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty,
::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty,
::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty,
::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty };
assert(SAL_N_ELEMENTS(aSmallPlaceHolders) == SAL_N_ELEMENTS(aBigPlaceHolders));

View file

@ -6101,6 +6101,7 @@ include/tools/helpers.hxx
include/tools/inetmime.hxx
include/tools/inetmsg.hxx
include/tools/inetstrm.hxx
include/tools/lazydelete.hxx
include/tools/line.hxx
include/tools/lineend.hxx
include/tools/link.hxx
@ -6295,7 +6296,6 @@ include/vcl/inputtypes.hxx
include/vcl/jobset.hxx
include/vcl/keycod.hxx
include/vcl/layout.hxx
include/vcl/lazydelete.hxx
include/vcl/lineinfo.hxx
include/vcl/mapmod.hxx
include/vcl/menu.hxx

View file

@ -21,6 +21,7 @@
#include <tools/debug.hxx>
#include <tools/globname.hxx>
#include <tools/lazydelete.hxx>
#include <sot/exchange.hxx>
#include <sot/formats.hxx>
#include <comphelper/classids.hxx>
@ -210,9 +211,9 @@ const DataFlavorRepresentation* FormatArray_Impl()
static tDataFlavorList& InitFormats_Impl()
{
static tDataFlavorList gImplData;
static tools::DeleteOnDeinit<tDataFlavorList> gImplData;
return gImplData;
return *gImplData.get();
}
/*************************************************************************

View file

@ -34,7 +34,7 @@
#include <basegfx/polygon/b2dpolygon.hxx>
#include <sdr/primitive2d/sdrattributecreator.hxx>
#include <sdr/primitive2d/sdrdecompositiontools.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <vcl/settings.hxx>
#include <drawinglayer/primitive2d/discreteshadowprimitive2d.hxx>
#include <drawinglayer/attribute/sdrfillattribute.hxx>
@ -135,7 +135,7 @@ void ViewContactOfPageShadow::createViewIndependentPrimitive2DSequence(drawingla
}
else
{
static vcl::DeleteOnDeinit< drawinglayer::primitive2d::DiscreteShadow > aDiscreteShadow((
static tools::DeleteOnDeinit< drawinglayer::primitive2d::DiscreteShadow > aDiscreteShadow((
BitmapEx(SIP_SA_PAGESHADOW35X35)));
if(aDiscreteShadow.get())

View file

@ -18,7 +18,7 @@
*/
#include <sdr/primitive2d/sdrprimitivetools.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <vcl/BitmapTools.hxx>
#include <mutex>
@ -29,7 +29,7 @@ namespace drawinglayer::primitive2d
{
BitmapEx createDefaultCross_3x3(const basegfx::BColor& rBColor)
{
static vcl::DeleteOnDeinit< BitmapEx > aRetVal(vcl::DeleteOnDeinitFlag::Empty);
static tools::DeleteOnDeinit< BitmapEx > aRetVal(tools::DeleteOnDeinitFlag::Empty);
static basegfx::BColor aBColor;
static std::mutex aMutex;

View file

@ -52,7 +52,7 @@
#include <svx/sdrpaintwindow.hxx>
#include <vcl/svapp.hxx>
#include <svx/sdr/overlay/overlaypolypolygon.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <vcl/BitmapTools.hxx>
#include <svx/sdr/contact/objectcontact.hxx>
#include <svx/sdr/contact/viewcontact.hxx>
@ -776,7 +776,7 @@ BitmapEx ImpGetBitmapEx(BitmapMarkerKind eKindOfMarker, BitmapColorIndex eIndex)
// if we can't load the marker...
static vcl::DeleteOnDeinit< SdrHdlBitmapSet > aModernSet {};
static tools::DeleteOnDeinit< SdrHdlBitmapSet > aModernSet {};
return aModernSet.get()->GetBitmapEx(eKindOfMarker, sal_uInt16(eIndex));
}

View file

@ -119,7 +119,7 @@
#include <rtl/character.hxx>
#include <tools/UnitConversion.hxx>
#include <o3tl/string_view.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
using namespace ::com::sun::star;
@ -509,7 +509,7 @@ void SdrObject::handlePageChange(SdrPage*, SdrPage* )
// init global static itempool
SdrItemPool& SdrObject::GetGlobalDrawObjectItemPool()
{
static vcl::DeleteRtlReferenceOnDeinit<SdrItemPool> xGlobalItemPool( []() {
static tools::DeleteRtlReferenceOnDeinit<SdrItemPool> xGlobalItemPool( []() {
rtl::Reference<SdrItemPool> xNewPool(new SdrItemPool());
rtl::Reference<SfxItemPool> pGlobalOutlPool = EditEngine::CreatePool();
xNewPool->SetSecondaryPool(pGlobalOutlPool.get());

View file

@ -117,7 +117,7 @@
#include <vcl/kernarray.hxx>
#include <vcl/keycod.hxx>
#include <vcl/keycodes.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <vcl/mapmod.hxx>
#include <vcl/metaactiontypes.hxx>
#include <vcl/outdev.hxx>

View file

@ -27,7 +27,7 @@
#include <stack>
#include <vcl/mapmod.hxx>
#include <vcl/vclptr.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <vcl/window.hxx>
namespace com::sun::star::accessibility { class XAccessible; }
@ -193,7 +193,7 @@ class SAL_DLLPUBLIC_RTTI SwViewShell : public sw::Ring<SwViewShell>
protected:
static ShellResource* spShellRes; ///< Resources for the Shell.
static vcl::DeleteOnDeinit< std::shared_ptr<weld::Window> > spCareDialog; ///< Avoid this window.
static tools::DeleteOnDeinit< std::shared_ptr<weld::Window> > spCareDialog; ///< Avoid this window.
SwRect maVisArea; ///< The modern version of VisArea.
tools::Rectangle maLOKVisibleArea;///< The visible area in the LibreOfficeKit client.

View file

@ -19,7 +19,7 @@
#include <utility>
#include <vcl/canvastools.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/printer.hxx>
#include <sfx2/progress.hxx>
@ -6400,19 +6400,19 @@ static void lcl_paintBitmapExToRect(vcl::RenderContext *pOut, const Point& aPoin
// #i16816# tagged pdf support
SwTaggedPDFHelper aTaggedPDFHelper( nullptr, nullptr, nullptr, *_pViewShell->GetOut() );
static vcl::DeleteOnDeinit<drawinglayer::primitive2d::DiscreteShadow> shadowMaskObj(
static tools::DeleteOnDeinit<drawinglayer::primitive2d::DiscreteShadow> shadowMaskObj(
vcl::bitmap::loadFromName(BMP_PAGE_SHADOW_MASK,
ImageLoadFlags::IgnoreDarkTheme | ImageLoadFlags::IgnoreScalingFactor));
drawinglayer::primitive2d::DiscreteShadow& shadowMask = *shadowMaskObj.get();
static vcl::DeleteOnDeinit< BitmapEx > aPageTopRightShadowObj {};
static vcl::DeleteOnDeinit< BitmapEx > aPageBottomRightShadowObj {};
static vcl::DeleteOnDeinit< BitmapEx > aPageBottomLeftShadowObj {};
static vcl::DeleteOnDeinit< BitmapEx > aPageBottomShadowBaseObj {};
static vcl::DeleteOnDeinit< BitmapEx > aPageRightShadowBaseObj {};
static vcl::DeleteOnDeinit< BitmapEx > aPageTopShadowBaseObj {};
static vcl::DeleteOnDeinit< BitmapEx > aPageTopLeftShadowObj {};
static vcl::DeleteOnDeinit< BitmapEx > aPageLeftShadowBaseObj {};
static tools::DeleteOnDeinit< BitmapEx > aPageTopRightShadowObj {};
static tools::DeleteOnDeinit< BitmapEx > aPageBottomRightShadowObj {};
static tools::DeleteOnDeinit< BitmapEx > aPageBottomLeftShadowObj {};
static tools::DeleteOnDeinit< BitmapEx > aPageBottomShadowBaseObj {};
static tools::DeleteOnDeinit< BitmapEx > aPageRightShadowBaseObj {};
static tools::DeleteOnDeinit< BitmapEx > aPageTopShadowBaseObj {};
static tools::DeleteOnDeinit< BitmapEx > aPageTopLeftShadowObj {};
static tools::DeleteOnDeinit< BitmapEx > aPageLeftShadowBaseObj {};
BitmapEx& aPageTopRightShadow = *aPageTopRightShadowObj.get();
BitmapEx& aPageBottomRightShadow = *aPageBottomRightShadowObj.get();
BitmapEx& aPageBottomLeftShadow = *aPageBottomLeftShadowObj.get();

View file

@ -26,7 +26,7 @@
#include <vcl/lineinfo.hxx>
#include <vcl/metric.hxx>
#include <vcl/svapp.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <vcl/glyphitemcache.hxx>
#include <com/sun/star/i18n/CharacterIteratorMode.hpp>
#include <com/sun/star/i18n/WordType.hpp>
@ -72,7 +72,7 @@ constexpr Color gWaveCol(COL_GRAY);
tools::Long SwFntObj::s_nPixWidth;
MapMode* SwFntObj::s_pPixMap = nullptr;
static vcl::DeleteOnDeinit< VclPtr<OutputDevice> > s_pFntObjPixOut {};
static tools::DeleteOnDeinit< VclPtr<OutputDevice> > s_pFntObjPixOut {};
void SwFntCache::Flush( )
{

View file

@ -89,7 +89,7 @@
bool SwViewShell::sbLstAct = false;
ShellResource *SwViewShell::spShellRes = nullptr;
vcl::DeleteOnDeinit<std::shared_ptr<weld::Window>> SwViewShell::spCareDialog {};
tools::DeleteOnDeinit<std::shared_ptr<weld::Window>> SwViewShell::spCareDialog {};
static bool bInSizeNotify = false;

View file

@ -72,6 +72,7 @@ $(eval $(call gb_Library_add_exception_objects,tl,\
tools/source/misc/cpuid \
tools/source/misc/extendapplicationenvironment \
tools/source/misc/json_writer \
tools/source/misc/lazydelete \
tools/source/misc/UniqueID \
tools/source/ref/globname \
tools/source/ref/ref \

View file

@ -17,42 +17,38 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <vcl/lazydelete.hxx>
#include <svdata.hxx>
#include <tools/lazydelete.hxx>
#include <sal/log.hxx>
#include <vector>
namespace vcl
namespace tools
{
DeleteOnDeinitBase::~DeleteOnDeinitBase()
{
ImplSVData* pSVData = ImplGetSVData();
if (!pSVData)
return;
auto& rList = pSVData->maDeinitDeleteList;
std::erase(rList, this);
}
static std::vector<tools::DeleteOnDeinitBase*> gDeinitDeleteList;
static bool gShutdown = false;
DeleteOnDeinitBase::~DeleteOnDeinitBase() { std::erase(gDeinitDeleteList, this); }
void DeleteOnDeinitBase::addDeinitContainer(DeleteOnDeinitBase* i_pContainer)
{
ImplSVData* pSVData = ImplGetSVData();
SAL_WARN_IF(pSVData->mbDeInit, "vcl", "DeleteOnDeinit added after DeiInitVCL !");
if (pSVData->mbDeInit)
if (gShutdown)
{
SAL_WARN("tools", "DeleteOnDeinit added after DeiInitVCL !");
return;
}
pSVData->maDeinitDeleteList.push_back(i_pContainer);
gDeinitDeleteList.push_back(i_pContainer);
}
void DeleteOnDeinitBase::ImplDeleteOnDeInit()
{
ImplSVData* pSVData = ImplGetSVData();
for (auto const& deinitDelete : pSVData->maDeinitDeleteList)
gShutdown = true;
for (auto const& deinitDelete : gDeinitDeleteList)
{
deinitDelete->doCleanup();
}
pSVData->maDeinitDeleteList.clear();
gDeinitDeleteList.clear();
}
} // namespace vcl
} // namespace tools
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -390,7 +390,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/helper/driverblocklist \
vcl/source/helper/evntpost \
vcl/source/helper/idletask \
vcl/source/helper/lazydelete \
vcl/source/helper/strhelper \
vcl/source/helper/svtaccessiblefactory \
vcl/source/helper/threadex \

View file

@ -348,7 +348,7 @@
#include <vcl/idle.hxx>
#include <vcl/image.hxx>
#include <vcl/layout.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <vcl/lineinfo.hxx>
#include <vcl/menu.hxx>
#include <vcl/metaact.hxx>

View file

@ -128,7 +128,6 @@ namespace vcl
{
class DisplayConnectionDispatch;
class SettingsConfigItem;
class DeleteOnDeinitBase;
class Window;
}
@ -421,7 +420,6 @@ struct ImplSVData
css::uno::Reference< css::lang::XComponent > mxAccessBridge;
std::unique_ptr<vcl::SettingsConfigItem> mpSettingsConfigItem;
std::vector< vcl::DeleteOnDeinitBase* > maDeinitDeleteList;
std::unordered_map< int, OUString > maPaperNames;
css::uno::Reference<css::i18n::XCharacterClassification> m_xCharClass;

View file

@ -23,7 +23,7 @@
#include <skia/salbmp.hxx>
#include <vcl/idle.hxx>
#include <vcl/svapp.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <vcl/gradient.hxx>
#include <vcl/skia/SkiaHelper.hxx>
#include <skia/utils.hxx>

View file

@ -45,7 +45,7 @@
#include <vcl/settings.hxx>
#include <vcl/toolkit/unowrap.hxx>
#include <configsettings.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <vcl/embeddedfontshelper.hxx>
#include <vcl/toolkit/dialog.hxx>
#include <vcl/menu.hxx>
@ -468,7 +468,7 @@ void DeInitVCL()
// Some events may need to access objects destroyed in ImplDeleteOnDeInit, so process them first
Scheduler::ProcessEventsToIdle();
vcl::DeleteOnDeinitBase::ImplDeleteOnDeInit();
tools::DeleteOnDeinitBase::ImplDeleteOnDeInit();
#if OSL_DEBUG_LEVEL > 0
OStringBuffer aBuf( 256 );

View file

@ -21,7 +21,7 @@
#include <utility>
#include <vcl/glyphitemcache.hxx>
#include <vcl/vcllayout.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <tools/stream.hxx>
#include <unotools/configmgr.hxx>
#include <TextLayoutCache.hxx>
@ -234,7 +234,7 @@ void SalLayoutGlyphsCache::clear() { mCachedGlyphs.clear(); }
SalLayoutGlyphsCache* SalLayoutGlyphsCache::self()
{
static vcl::DeleteOnDeinit<SalLayoutGlyphsCache> cache(
static tools::DeleteOnDeinit<SalLayoutGlyphsCache> cache(
!comphelper::IsFuzzing() ? officecfg::Office::Common::Cache::Font::GlyphsCacheSize::get()
: 20000000);
return cache.get();

View file

@ -8,7 +8,7 @@
*/
#include <memory>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <vcl/syschild.hxx>
#include <svdata.hxx>

View file

@ -24,7 +24,7 @@
#include <tools/debug.hxx>
#include <vcl/graph.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <vcl/metaact.hxx>
#include <vcl/toolkit/unowrap.hxx>
#include <vcl/svapp.hxx>
@ -788,7 +788,7 @@ com::sun::star::uno::Reference< css::rendering::XCanvas > OutputDevice::ImplGetC
Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
static vcl::DeleteUnoReferenceOnDeinit<css::lang::XMultiComponentFactory> xStaticCanvasFactory(
static tools::DeleteUnoReferenceOnDeinit<css::lang::XMultiComponentFactory> xStaticCanvasFactory(
css::rendering::CanvasFactory::create( xContext ) );
Reference<css::lang::XMultiComponentFactory> xCanvasFactory(xStaticCanvasFactory.get());
Reference< css::rendering::XCanvas > xCanvas;

View file

@ -24,7 +24,7 @@
#include <o3tl/hash_combine.hxx>
#include <o3tl/lru_map.hxx>
#include <comphelper/configuration.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <vcl/metaact.hxx>
#include <vcl/settings.hxx>
#include <vcl/virdev.hxx>
@ -1051,7 +1051,7 @@ void OutputDevice::DrawWaveLine(const Point& rStartPos, const Point& rEndPos, to
if ( fOrientation == 0.0 )
{
static vcl::DeleteOnDeinit< WavyLineCache > snLineCache {};
static tools::DeleteOnDeinit< WavyLineCache > snLineCache {};
if ( !snLineCache.get() )
return;
WavyLineCache& rLineCache = *snLineCache.get();

View file

@ -24,7 +24,7 @@
#include <o3tl/hash_combine.hxx>
#include <o3tl/lru_map.hxx>
#include <unotools/configmgr.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <officecfg/Office/Common.hxx>
namespace vcl::text
@ -55,7 +55,7 @@ std::shared_ptr<const TextLayoutCache> TextLayoutCache::Create(OUString const& r
typedef o3tl::lru_map<OUString, std::shared_ptr<const TextLayoutCache>, FirstCharsStringHash,
FastStringCompareEqual, TextLayoutCacheCost>
Cache;
static vcl::DeleteOnDeinit<Cache> cache(
static tools::DeleteOnDeinit<Cache> cache(
!comphelper::IsFuzzing() ? officecfg::Office::Common::Cache::Font::TextRunsCacheSize::get()
: 100);
if (Cache* map = cache.get())

View file

@ -27,7 +27,7 @@
#include <vcl/lineinfo.hxx>
#include <vcl/settings.hxx>
#include <vcl/ptrstyle.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <window.h>
@ -35,12 +35,12 @@ namespace
{
Wallpaper& ImplBlackWall()
{
static vcl::DeleteOnDeinit< Wallpaper > SINGLETON(COL_BLACK);
static tools::DeleteOnDeinit< Wallpaper > SINGLETON(COL_BLACK);
return *SINGLETON.get();
}
Wallpaper& ImplWhiteWall()
{
static vcl::DeleteOnDeinit< Wallpaper > SINGLETON(COL_LIGHTGRAY);
static tools::DeleteOnDeinit< Wallpaper > SINGLETON(COL_LIGHTGRAY);
return *SINGLETON.get();
}
}

View file

@ -38,7 +38,7 @@
#include <vcl/toolkit/button.hxx>
#include <vcl/taskpanelist.hxx>
#include <vcl/toolkit/unowrap.hxx>
#include <vcl/lazydelete.hxx>
#include <tools/lazydelete.hxx>
#include <vcl/virdev.hxx>
#include <vcl/settings.hxx>
#include <vcl/sysdata.hxx>
@ -3747,7 +3747,7 @@ Reference< css::rendering::XCanvas > WindowOutputDevice::ImplGetCanvas( bool bSp
// Create canvas instance with window handle
static vcl::DeleteUnoReferenceOnDeinit<XMultiComponentFactory> xStaticCanvasFactory(
static tools::DeleteUnoReferenceOnDeinit<XMultiComponentFactory> xStaticCanvasFactory(
css::rendering::CanvasFactory::create( xContext ) );
Reference<XMultiComponentFactory> xCanvasFactory(xStaticCanvasFactory.get());
Reference< css::rendering::XCanvas > xCanvas;