[Libreoffice-commits] core.git: sw/inc sw/Library_sw.mk sw/source

Stephan Bergmann sbergman at redhat.com
Fri Mar 20 11:35:23 PDT 2015


 sw/Library_sw.mk                               |    1 
 sw/inc/proofreadingiterator.hxx                |   39 ++++++++++++++
 sw/source/core/bastyp/init.cxx                 |    2 
 sw/source/core/bastyp/proofreadingiterator.cxx |   69 +++++++++++++++++++++++++
 sw/source/core/doc/docnew.cxx                  |    4 -
 sw/source/uibase/uno/dlelstnr.cxx              |    4 -
 6 files changed, 115 insertions(+), 4 deletions(-)

New commits:
commit 39c1c3584e6f730c4f78541e259c49fdea5cb428
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Mar 20 18:29:17 2015 +0000

    Ensure GrammarCheckingIterator thread is joined before SwBreakIt::_Delete
    
    ...because SwBreakIt::_Delete clears g_pBreakIt but SwTxtNode::GetLang (called
    indirectly from GrammarCheckingIterator::DequeueAndCheck) expects it to be non-
    null.  That caused CppunitTest_libreofficekit_tiledrendering to occasionally
    fail.
    
    Change-Id: Ia350e2531067dd8308dfa20567cc00e1140f764c

diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 5254e3a..d27dbf6 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -130,6 +130,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     sw/source/core/bastyp/checkit \
     sw/source/core/bastyp/index \
     sw/source/core/bastyp/init \
+    sw/source/core/bastyp/proofreadingiterator \
     sw/source/core/bastyp/swcache \
     sw/source/core/bastyp/swrect \
     sw/source/core/bastyp/swregion \
diff --git a/sw/inc/proofreadingiterator.hxx b/sw/inc/proofreadingiterator.hxx
new file mode 100644
index 0000000..953efcf
--- /dev/null
+++ b/sw/inc/proofreadingiterator.hxx
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SW_INC_PROOFREADINGITERATOR_HXX
+#define INCLUDED_SW_INC_PROOFREADINGITERATOR_HXX
+
+#include <sal/config.h>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <sal/types.h>
+
+namespace com { namespace sun { namespace star {
+    namespace linguistic2 { class XProofreadingIterator; }
+    namespace uno { class XComponentContext; }
+} } }
+
+// A simple wrapper around the css.linguistic2.ProofreadingIterator
+// single-instance service.  The first time that service implementation gets
+// instantiated it immediately starts a GrammarCheckingIterator thread that
+// eventually needs to be joined (via dispose):
+
+namespace sw { namespace proofreadingiterator {
+
+css::uno::Reference<css::linguistic2::XProofreadingIterator> get(
+    css::uno::Reference<css::uno::XComponentContext> const & context);
+
+void dispose();
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx
index 074e372..6e39a13 100644
--- a/sw/source/core/bastyp/init.cxx
+++ b/sw/source/core/bastyp/init.cxx
@@ -109,6 +109,7 @@
 #include <init.hxx>
 #include <pam.hxx>
 #include <paratr.hxx>
+#include <proofreadingiterator.hxx>
 #include <rtl/instance.hxx>
 #include <svl/macitem.hxx>
 #include <svx/dialogs.hrc>
@@ -749,6 +750,7 @@ void _FinitCore()
     _FrmFinit();
     _TextFinit();
 
+    sw::proofreadingiterator::dispose();
     SwBreakIt::_Delete();
     delete pCheckIt;
     delete pAppCharClass;
diff --git a/sw/source/core/bastyp/proofreadingiterator.cxx b/sw/source/core/bastyp/proofreadingiterator.cxx
new file mode 100644
index 0000000..b0f7547
--- /dev/null
+++ b/sw/source/core/bastyp/proofreadingiterator.cxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sal/config.h>
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/linguistic2/ProofreadingIterator.hpp>
+#include <com/sun/star/linguistic2/XProofreadingIterator.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <sal/types.h>
+#include <vcl/svapp.hxx>
+
+#include <proofreadingiterator.hxx>
+
+namespace {
+
+css::uno::Reference<css::linguistic2::XProofreadingIterator> instance;
+bool disposed = false;
+
+void doDispose(
+    css::uno::Reference<css::linguistic2::XProofreadingIterator> const &
+        inst)
+{
+    css::uno::Reference<css::lang::XComponent> comp(inst, css::uno::UNO_QUERY);
+    if (comp.is()) {
+        SolarMutexReleaser r;
+        comp->dispose();
+    }
+}
+
+}
+
+css::uno::Reference<css::linguistic2::XProofreadingIterator>
+sw::proofreadingiterator::get(
+    css::uno::Reference<css::uno::XComponentContext> const & context)
+{
+    css::uno::Reference<css::linguistic2::XProofreadingIterator> inst(
+        css::linguistic2::ProofreadingIterator::create(context));
+    bool disp;
+    {
+        SolarMutexGuard g;
+        instance = inst;
+        disp = disposed;
+    }
+    if (disp) {
+        doDispose(inst);
+    }
+    return inst;
+}
+
+void sw::proofreadingiterator::dispose() {
+    css::uno::Reference<css::linguistic2::XProofreadingIterator> inst;
+    {
+        SolarMutexGuard g;
+        inst = instance;
+        instance.clear();
+        disposed = true;
+    }
+    doDispose(inst);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 2fc0dce..b45451f 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -21,10 +21,10 @@
 
 #include <doc.hxx>
 #include <dcontact.hxx>
+#include <proofreadingiterator.hxx>
 #include <com/sun/star/document/PrinterIndependentLayout.hpp>
 #include <com/sun/star/document/UpdateDocMode.hpp>
 #include <com/sun/star/text/XTextDocument.hpp>
-#include <com/sun/star/linguistic2/ProofreadingIterator.hpp>
 #include <com/sun/star/text/XFlatParagraphIteratorProvider.hpp>
 
 #include <comphelper/processfactory.hxx>
@@ -140,7 +140,7 @@ const sal_Char sGrfCollStr[] = "Graphikformatvorlage";
         uno::Reference< uno::XComponentContext >  xContext( comphelper::getProcessComponentContext() );
         try
         {
-            m_xGCIterator = linguistic2::ProofreadingIterator::create( xContext );
+            m_xGCIterator = sw::proofreadingiterator::get( xContext );
         }
         catch (const uno::Exception &)
         {
diff --git a/sw/source/uibase/uno/dlelstnr.cxx b/sw/source/uibase/uno/dlelstnr.cxx
index da97f5f..195ebae 100644
--- a/sw/source/uibase/uno/dlelstnr.cxx
+++ b/sw/source/uibase/uno/dlelstnr.cxx
@@ -22,7 +22,6 @@
 #include <com/sun/star/linguistic2/XDictionaryList.hpp>
 #include <com/sun/star/linguistic2/LinguServiceManager.hpp>
 #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
-#include <com/sun/star/linguistic2/ProofreadingIterator.hpp>
 #include <com/sun/star/linguistic2/LinguServiceEventFlags.hpp>
 
 #include <unotools/lingucfg.hxx>
@@ -32,6 +31,7 @@
 #include <osl/mutex.hxx>
 #include <vcl/svapp.hxx>
 #include "dlelstnr.hxx"
+#include <proofreadingiterator.hxx>
 #include <swmodule.hxx>
 #include <wrtsh.hxx>
 #include <view.hxx>
@@ -56,7 +56,7 @@ SwLinguServiceEventListener::SwLinguServiceEventListener()
 
         if (SvtLinguConfig().HasGrammarChecker())
         {
-            xGCIterator = ProofreadingIterator::create(xContext);
+            xGCIterator = sw::proofreadingiterator::get(xContext);
             Reference< XLinguServiceEventBroadcaster > xBC( xGCIterator, UNO_QUERY );
             if (xBC.is())
                 xBC->addLinguServiceEventListener( (XLinguServiceEventListener *) this );


More information about the Libreoffice-commits mailing list