summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2024-01-09 12:29:52 +0100
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-01-09 20:40:49 +0100
commit6a0d4247b73d16d7e70ab146aadfbed75721f8bd (patch)
treeba2a48ca05fd42a53c0e69567fa5ec56c7b003a1
parent02ffa01b5e2e7697d6b386419e88a9b8910ad31f (diff)
Revert "simplify SfxItemDisruptor_Impl, just use Application::PostUserEvent"
This reverts commit 57145acf9ec47c23e307b7a5c0029d21d937cc35. According to 789a737ac92c4f2b0eb9820b99c43cc8253c8b29 "Remove DeleteItemOnIdlex" There are some CrashReports in 7.6 which have DeleteItemOnIdle on the stack... DeleteItemOnIdle exists since 1st import, but was changed to AsyncEvent ca. 4 months ago (see 57145acf9ec47c23e307b7a5c0029d21d937cc35), so that may have caused it. Reverting this patch in libreoffice-7-6 only to see if it fixes https://crashreport.libreoffice.org/stats/signature/static%20bool%20cppu::idefaultConstructElements(struct%20_sal_Sequence%20*%20*,%20struct%20_typelib_TypeDescriptionReference%20*,%20long,%20long,%20long) Change-Id: Ic6d1046e43295d719a928615a1be921ab5596326 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161823 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sfx2/source/control/itemdel.cxx47
1 files changed, 34 insertions, 13 deletions
diff --git a/sfx2/source/control/itemdel.cxx b/sfx2/source/control/itemdel.cxx
index c96a9d0f4ba3..2b8e7db73fc6 100644
--- a/sfx2/source/control/itemdel.cxx
+++ b/sfx2/source/control/itemdel.cxx
@@ -22,35 +22,56 @@
#include <itemdel.hxx>
#include <svl/poolitem.hxx>
#include <vcl/idle.hxx>
-#include <vcl/svapp.hxx>
#include <tools/debug.hxx>
class SfxItemDisruptor_Impl
{
+ std::unique_ptr<SfxPoolItem> pItem;
+ Idle m_Idle;
+
+private:
+ DECL_LINK(Delete, Timer*, void);
+
public:
- static void DeleteItemOnIdle(std::unique_ptr<SfxPoolItem> pItem)
- {
- pItem->SetKind(SfxItemKind::DeleteOnIdle);
- Application::PostUserEvent(LINK(nullptr, SfxItemDisruptor_Impl, Delete), pItem.release());
- // coverity[leaked_storage] - pDisruptor takes care of its own destruction at idle time
- }
-
- DECL_STATIC_LINK(SfxItemDisruptor_Impl, Delete, void*, void);
+ explicit SfxItemDisruptor_Impl(std::unique_ptr<SfxPoolItem> pItemToDesrupt);
+ void LaunchDeleteOnIdle();
+ ~SfxItemDisruptor_Impl();
+ SfxItemDisruptor_Impl(const SfxItemDisruptor_Impl&) = delete;
+ SfxItemDisruptor_Impl& operator=(const SfxItemDisruptor_Impl&) = delete;
};
-IMPL_STATIC_LINK(SfxItemDisruptor_Impl, Delete, void*, p, void)
+SfxItemDisruptor_Impl::SfxItemDisruptor_Impl(std::unique_ptr<SfxPoolItem> pItemToDisrupt)
+ : pItem(std::move(pItemToDisrupt))
+ , m_Idle("sfx::SfxItemDisruptor_Impl m_Idle")
+{
+ m_Idle.SetInvokeHandler(LINK(this, SfxItemDisruptor_Impl, Delete));
+ m_Idle.SetPriority(TaskPriority::DEFAULT_IDLE);
+
+ DBG_ASSERT(0 == pItem->GetRefCount(), "disrupting pooled item");
+ pItem->SetKind(SfxItemKind::DeleteOnIdle);
+}
+
+void SfxItemDisruptor_Impl::LaunchDeleteOnIdle() { m_Idle.Start(); }
+
+SfxItemDisruptor_Impl::~SfxItemDisruptor_Impl()
{
- SfxPoolItem* pItem = static_cast<SfxPoolItem*>(p);
+ m_Idle.Stop();
+
// reset RefCount (was set to SFX_ITEMS_SPECIAL before!)
pItem->SetRefCount(0);
- delete pItem;
+
+ pItem.reset();
}
+IMPL_LINK_NOARG(SfxItemDisruptor_Impl, Delete, Timer*, void) { delete this; }
+
void DeleteItemOnIdle(std::unique_ptr<SfxPoolItem> pItem)
{
DBG_ASSERT(0 == pItem->GetRefCount(), "deleting item in use");
- SfxItemDisruptor_Impl::DeleteItemOnIdle(std::move(pItem));
+ SfxItemDisruptor_Impl* pDesruptor = new SfxItemDisruptor_Impl(std::move(pItem));
+ pDesruptor->LaunchDeleteOnIdle();
+ // coverity[leaked_storage] - pDesruptor takes care of its own destruction at idle time
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */