linguistic/source/gciterator.cxx |    7 +++----
 linguistic/source/gciterator.hxx |    7 +++----
 2 files changed, 6 insertions(+), 8 deletions(-)

New commits:
commit c630c3121bdf00dae72586b01dd0517328ba89ff
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Jun 2 14:32:45 2023 +0300
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Mon Jun 5 14:28:39 2023 +0200

    tdf#155647: Pass XFlatParagraph by normal Reference, not WeakReference
    
    Since commit a7ce722b476c4bb0c9a113ae0c2759181edfe48f (tdf#155232:
    drop m_aFlatParaList from SwXFlatParagraphIterator, 2023-05-13), the
    instances of XFlatParagraph are not cached in its iterator. Hence,
    the instances created in GrammarCheckingIterator to pass to AddEntry
    got immediately destroyed upon the scope end, before the checking
    thread (where weak references were passed) had a chance to create own
    hard references. Then GrammarCheckingIterator::DequeueAndCheck found
    that xFlatPara was empty, and exited.
    
    Just pass hard references there. The iterator was passed to the thread
    by hard reference in FPEntry anyway; and so, the use of weak reference
    to flat paragraph objects provided no benefit, when the iterator kept
    hard references.
    
    Change-Id: Ib56652d88b9a5c6f20aa3d70fed18f8be0d3a3df
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152554
    Tested-by: Mike Kaganski <mike.kagan...@collabora.com>
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    (cherry picked from commit 72869f559021ced673465cb9aa82e461ecaafc91)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152532
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx
index 993b0258db32..301e1319c1d8 100644
--- a/linguistic/source/gciterator.cxx
+++ b/linguistic/source/gciterator.cxx
@@ -345,16 +345,15 @@ OUString GrammarCheckingIterator::GetOrCreateDocId(
 
 
 void GrammarCheckingIterator::AddEntry(
-    const uno::WeakReference< text::XFlatParagraphIterator >& 
xFlatParaIterator,
-    const uno::WeakReference< text::XFlatParagraph >& xFlatPara,
+    const uno::Reference< text::XFlatParagraphIterator >& xFlatParaIterator,
+    const uno::Reference< text::XFlatParagraph >& xFlatPara,
     const OUString & rDocId,
     sal_Int32 nStartIndex,
     bool bAutomatic )
 {
     // we may not need/have a xFlatParaIterator (e.g. if checkGrammarAtPos was 
called)
     // but we always need a xFlatPara...
-    uno::Reference< text::XFlatParagraph > xPara( xFlatPara );
-    if (!xPara.is())
+    if (!xFlatPara.is())
         return;
 
     FPEntry aNewFPEntry;
diff --git a/linguistic/source/gciterator.hxx b/linguistic/source/gciterator.hxx
index f159a9ad968f..f4123d58cf53 100644
--- a/linguistic/source/gciterator.hxx
+++ b/linguistic/source/gciterator.hxx
@@ -30,7 +30,6 @@
 #include <com/sun/star/util/XChangesBatch.hpp>
 
 #include <cppuhelper/implbase.hxx>
-#include <cppuhelper/weakref.hxx>
 #include <osl/mutex.hxx>
 #include <osl/conditn.hxx>
 #include <osl/thread.h>
@@ -53,7 +52,7 @@ struct FPEntry
     css::uno::Reference< css::text::XFlatParagraphIterator > m_xParaIterator;
 
     // flat paragraph
-    css::uno::WeakReference< css::text::XFlatParagraph > m_xPara;
+    css::uno::Reference< css::text::XFlatParagraph > m_xPara;
 
     // document ID to identify different documents
     OUString        m_aDocId;
@@ -127,8 +126,8 @@ class GrammarCheckingIterator:
     OUString GetOrCreateDocId( const css::uno::Reference< 
css::lang::XComponent > &xComp );
 
     void AddEntry(
-            const css::uno::WeakReference< css::text::XFlatParagraphIterator 
>& xFlatParaIterator,
-            const css::uno::WeakReference< css::text::XFlatParagraph >& 
xFlatPara,
+            const css::uno::Reference< css::text::XFlatParagraphIterator >& 
xFlatParaIterator,
+            const css::uno::Reference< css::text::XFlatParagraph >& xFlatPara,
             const OUString &rDocId, sal_Int32 nStartIndex, bool bAutomatic );
 
     void ProcessResult( const css::linguistic2::ProofreadingResult &rRes,

Reply via email to