Kaydet (Commit) 39c1c358 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

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
üst 317c8e5c
......@@ -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 \
......
/* -*- 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: */
......@@ -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;
......
/* -*- 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: */
......@@ -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 &)
{
......
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment