diff options
author | Armin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de> | 2023-08-14 18:21:13 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2023-08-18 10:37:44 +0200 |
commit | c351f920c426542f0d3685bb9df1363d3a6393f8 (patch) | |
tree | 537d3a9bbe3df1a17ca62f0cb05fbc225caaaccb /include/svl/poolitem.hxx | |
parent | a43a9dd8205f089c92737cb5519ed2a96a8d8ff2 (diff) |
ITEM: preparations for more/easier changes
This change is not about speed improvements but diverse
preparations to make changes/reading/understanding easier.
It does not change speed AFAIK.
Added a global static debug-only counter to allow getting
an overview over number of all allocated SfxPoolItem's
and the still alloated ones at office shutdown. The values
are used in Application::~Application to make a short info
statement. It allows to be able to quickly detect if an
error in future changes may lead to memory losses - these
would show in dramaitically higher numbers then (hopefully)
immediately.
Moved SfxVoidItem to own source/header.
Added container library interface support to SfxItemSet,
adapted already some methods to use it - not all possible,
I will commit & get status from gerrit 1st if all still works
and then continue.
Changed INVALID_POOL_ITEM from -1 to use a global unique
incarnation of an isolated derivation from SfxPoolItem. It
allows to avoid the (-1) pointer hack. Since still just
pointers are compared it's not worse. NOTE: That way, more
'special' SfxPoolItem's may be used for more States - a
candidate is e.g. SfxVoidItem(0) which represents ::DISABLED
state -- unfortunately not only, it is also used (mainly for
UI stuff) with 'real' WhichIDs - hard to sort out, will have
to stay that way for now AFAIK.
Changed INVALID_POOL_ITEM stuff to use a static extern
incarnated item in combination with a inline method
to return it, called GetGlobalStaticInvalidItemInstance().
Isolated create/cleanup of a SfxPoolItem entry in
SfxItemSet to further modularize/simplify that. It is
currently from constructor & destructor but already shows
that PoolDefaults are handled differently - probably an
error. Still, for now, do no change in behaviour (yet).
Got regular 'killed by the Kill-Wrapper' messages from
gerrit, seems to have to do with UITest_sw_findReplace.
That python/c++ scripting stuff is hard to debug, but
finally I identified the problem has to do with
the INVALID_POOL_ITEM change. It was in
SfxItemSet::InvalidateAllItems() where still a (-1)
was used -> chaos in detecting invalid items.
Change-Id: I595e1f25ab660c35c4f2d19c233d1dfadfe25214
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155675
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'include/svl/poolitem.hxx')
-rw-r--r-- | include/svl/poolitem.hxx | 37 |
1 files changed, 6 insertions, 31 deletions
diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx index 10a7901b4e70..46dd8b0a76f5 100644 --- a/include/svl/poolitem.hxx +++ b/include/svl/poolitem.hxx @@ -106,7 +106,10 @@ enum class SfxItemState { SET = 0x0040 }; -#define INVALID_POOL_ITEM reinterpret_cast<SfxPoolItem*>(-1) +#ifdef DBG_UTIL +SVL_DLLPUBLIC size_t getAllocatedSfxPoolItemCount(); +SVL_DLLPUBLIC size_t getUsedSfxPoolItemCount(); +#endif class SfxItemPool; class SfxItemSet; @@ -118,7 +121,6 @@ friend class SfxItemPool; friend class SfxItemDisruptor_Impl; friend class SfxItemPoolCache; friend class SfxItemSet; -friend class SfxVoidItem; mutable sal_uInt32 m_nRefCount; sal_uInt16 m_nWhich; @@ -286,40 +288,13 @@ inline bool IsPooledItem( const SfxPoolItem *pItem ) return pItem && pItem->GetRefCount() > 0 && pItem->GetRefCount() <= SFX_ITEMS_MAXREF; } +SVL_DLLPUBLIC extern SfxPoolItem const * const INVALID_POOL_ITEM; + inline bool IsInvalidItem(const SfxPoolItem *pItem) { return pItem == INVALID_POOL_ITEM; } -class SVL_DLLPUBLIC SfxVoidItem final: public SfxPoolItem -{ -public: - static SfxPoolItem* CreateDefault(); - explicit SfxVoidItem( sal_uInt16 nWhich ); - virtual ~SfxVoidItem() override; - - SfxVoidItem(SfxVoidItem const &) = default; - SfxVoidItem(SfxVoidItem &&) = default; - SfxVoidItem & operator =(SfxVoidItem const &) = delete; // due to SfxPoolItem - SfxVoidItem & operator =(SfxVoidItem &&) = delete; // due to SfxPoolItem - - virtual bool operator==( const SfxPoolItem& ) const override; - - virtual bool GetPresentation( SfxItemPresentation ePres, - MapUnit eCoreMetric, - MapUnit ePresMetric, - OUString &rText, - const IntlWrapper& ) const override; - virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override; - - // create a copy of itself - virtual SfxVoidItem* Clone( SfxItemPool *pPool = nullptr ) const override; - - /** Always returns true as this is an SfxVoidItem. */ - virtual bool IsVoidItem() const override; -}; - - class SVL_DLLPUBLIC SfxPoolItemHint final : public SfxHint { SfxPoolItem* pObj; |