include/comphelper/interfacecontainer4.hxx |   30 +++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

New commits:
commit dac1ad8a991c51bddcb87b28063b20cf4ed87dbe
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Nov 22 12:24:01 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Dec 3 14:00:39 2022 +0000

    tdf#152077 Calc freeze when you draw a line inside the chart
    
    Change-Id: Ia047352033780c658aa7244cb8568392cf23baac
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143103
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143283

diff --git a/include/comphelper/interfacecontainer4.hxx 
b/include/comphelper/interfacecontainer4.hxx
index 694e5b17bbca..bdd6a6b60631 100644
--- a/include/comphelper/interfacecontainer4.hxx
+++ b/include/comphelper/interfacecontainer4.hxx
@@ -366,22 +366,28 @@ template <class ListenerT>
 void 
OInterfaceContainerHelper4<ListenerT>::disposeAndClear(std::unique_lock<std::mutex>&
 rGuard,
                                                             const 
css::lang::EventObject& rEvt)
 {
-    OInterfaceIteratorHelper4<ListenerT> aIt(rGuard, *this);
-    maData->clear();
-    rGuard.unlock();
-    // unlock followed by iterating is only safe because we are not going to 
call remove() on the iterator
-    while (aIt.hasMoreElements())
     {
-        try
-        {
-            aIt.next()->disposing(rEvt);
-        }
-        catch (css::uno::RuntimeException&)
+        OInterfaceIteratorHelper4<ListenerT> aIt(rGuard, *this);
+        maData
+            = DEFAULT(); // cheaper than calling maData->clear() because it 
doesn't allocate a new vector
+        rGuard.unlock();
+        // unlock followed by iterating is only safe because we are not going 
to call remove() on the iterator
+        while (aIt.hasMoreElements())
         {
-            // be robust, if e.g. a remote bridge has disposed already.
-            // there is no way to delegate the error to the caller :o(.
+            try
+            {
+                aIt.next()->disposing(rEvt);
+            }
+            catch (css::uno::RuntimeException&)
+            {
+                // be robust, if e.g. a remote bridge has disposed already.
+                // there is no way to delegate the error to the caller :o(.
+            }
         }
     }
+    // tdf#152077 need to destruct the OInterfaceIteratorHelper4 before we 
take the lock again
+    // because there is a vague chance that destructing it will trigger a call 
back into something
+    // that wants to take the lock.
     rGuard.lock();
 }
 

Reply via email to