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

New commits:
commit 72869f559021ced673465cb9aa82e461ecaafc91
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Jun 2 14:32:45 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Jun 2 15:43:23 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>

diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx
index 1cd8883705c7..5ab816dfa802 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 18984d398165..e25b15a96226 100644
--- a/linguistic/source/gciterator.hxx
+++ b/linguistic/source/gciterator.hxx
@@ -29,7 +29,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>
@@ -52,7 +51,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;
@@ -126,8 +125,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