drawinglayer/source/primitive2d/BufferedDecompositionFlusher.cxx  |   16 
++++++++++
 include/drawinglayer/primitive2d/BufferedDecompositionFlusher.hxx |    3 +
 2 files changed, 19 insertions(+)

New commits:
commit b816410089ea57494bf74581dc06cc0bfcd2350c
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Mar 20 12:31:46 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Mar 20 13:21:50 2025 +0100

    fix BufferedDecompositionFlusher shutdown crash (2)
    
    stopping the timer doesn't seem to be sufficient, try deleting all of
    the contained data at that point in time too.
    
    regression from
        commit 8a17b7f0a679ebf21bcfb425186b205d996d129b
        Author: Noel Grandin <noelgran...@gmail.com>
        Date:   Thu Mar 13 18:37:54 2025 +0200
        tdf#131595 Improve drawinglayer flushing mechanism.
    
    Change-Id: Ic11f287e83c482bfa81b5efb6b378113d15ecd0d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183164
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/drawinglayer/source/primitive2d/BufferedDecompositionFlusher.cxx 
b/drawinglayer/source/primitive2d/BufferedDecompositionFlusher.cxx
index a81b88514c9d..fd19f398ae8b 100644
--- a/drawinglayer/source/primitive2d/BufferedDecompositionFlusher.cxx
+++ b/drawinglayer/source/primitive2d/BufferedDecompositionFlusher.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <sal/config.h>
+#include <sal/log.hxx>
 
 #include <drawinglayer/primitive2d/BufferedDecompositionFlusher.hxx>
 #include <tools/lazydelete.hxx>
@@ -45,7 +46,9 @@ class FlusherDeinit : public tools::DeleteOnDeinitBase
     rtl::Reference<BufferedDecompositionFlusher> m_xTimer;
     virtual void doCleanup() override
     {
+        SAL_WARN("drawinglayer", "tearing down BufferedDecompositionFlusher");
         m_xTimer->stop();
+        m_xTimer->onTeardown();
         m_xTimer = nullptr;
     }
 
@@ -134,6 +137,19 @@ void SAL_CALL BufferedDecompositionFlusher::onShot()
     start();
 }
 
+/// Only called by FlusherDeinit
+void BufferedDecompositionFlusher::onTeardown()
+{
+    std::unordered_set<rtl::Reference<BufferedDecompositionPrimitive2D>> 
aRemoved1;
+    std::unordered_set<rtl::Reference<BufferedDecompositionGroupPrimitive2D>> 
aRemoved2;
+    {
+        std::unique_lock l(maMutex);
+        aRemoved1 = std::move(maRegistered1);
+        aRemoved2 = std::move(maRegistered2);
+    }
+    // let them destruct outside the lock
+}
+
 } // end of namespace drawinglayer::primitive2d
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/drawinglayer/primitive2d/BufferedDecompositionFlusher.hxx 
b/include/drawinglayer/primitive2d/BufferedDecompositionFlusher.hxx
index 26fbea502414..e1afcb75d31d 100644
--- a/include/drawinglayer/primitive2d/BufferedDecompositionFlusher.hxx
+++ b/include/drawinglayer/primitive2d/BufferedDecompositionFlusher.hxx
@@ -34,6 +34,9 @@ public:
 
     BufferedDecompositionFlusher();
 
+    /// Only called by FlusherDeinit
+    void onTeardown();
+
 private:
     virtual void SAL_CALL onShot() override;
     void updateImpl(const BufferedDecompositionPrimitive2D*);

Reply via email to