Fix double-clear of clearable mutex guard
Change-Id: I91f04cae91cbb5510f70baaf8c31ecc59f6402c7 Reviewed-on: https://gerrit.libreoffice.org/70479 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
@@ -611,57 +611,63 @@ void GrammarCheckingIterator::DequeueAndCheck()
|
||||
const bool bModified = xFlatPara->isModified();
|
||||
if (!bModified)
|
||||
{
|
||||
// ---- THREAD SAFE START ----
|
||||
::osl::ClearableGuard< ::osl::Mutex > aGuard( MyMutex::get() );
|
||||
|
||||
sal_Int32 nStartPos = aFPEntryItem.m_nStartIndex;
|
||||
sal_Int32 nSuggestedEnd = GetSuggestedEndOfSentence( aCurTxt, nStartPos, aCurLocale );
|
||||
DBG_ASSERT( (nSuggestedEnd == 0 && aCurTxt.isEmpty()) || nSuggestedEnd > nStartPos,
|
||||
"nSuggestedEndOfSentencePos calculation failed?" );
|
||||
|
||||
linguistic2::ProofreadingResult aRes;
|
||||
|
||||
uno::Reference< linguistic2::XProofreader > xGC( GetGrammarChecker( aCurLocale ), uno::UNO_QUERY );
|
||||
if (xGC.is())
|
||||
// ---- THREAD SAFE START ----
|
||||
{
|
||||
aGuard.clear();
|
||||
uno::Sequence<beans::PropertyValue> const aProps(
|
||||
lcl_makeProperties(xFlatPara));
|
||||
aRes = xGC->doProofreading( aCurDocId, aCurTxt,
|
||||
aCurLocale, nStartPos, nSuggestedEnd, aProps );
|
||||
osl::ClearableMutexGuard aGuard(MyMutex::get());
|
||||
|
||||
//!! work-around to prevent looping if the grammar checker
|
||||
//!! failed to properly identify the sentence end
|
||||
if (
|
||||
aRes.nBehindEndOfSentencePosition <= nStartPos &&
|
||||
aRes.nBehindEndOfSentencePosition != nSuggestedEnd
|
||||
)
|
||||
sal_Int32 nStartPos = aFPEntryItem.m_nStartIndex;
|
||||
sal_Int32 nSuggestedEnd
|
||||
= GetSuggestedEndOfSentence(aCurTxt, nStartPos, aCurLocale);
|
||||
DBG_ASSERT((nSuggestedEnd == 0 && aCurTxt.isEmpty())
|
||||
|| nSuggestedEnd > nStartPos,
|
||||
"nSuggestedEndOfSentencePos calculation failed?");
|
||||
|
||||
uno::Reference<linguistic2::XProofreader> xGC(
|
||||
GetGrammarChecker(aCurLocale), uno::UNO_QUERY);
|
||||
if (xGC.is())
|
||||
{
|
||||
SAL_WARN( "linguistic", "!! Grammarchecker failed to provide end of sentence !!" );
|
||||
aGuard.clear();
|
||||
uno::Sequence<beans::PropertyValue> const aProps(
|
||||
lcl_makeProperties(xFlatPara));
|
||||
aRes = xGC->doProofreading(aCurDocId, aCurTxt, aCurLocale,
|
||||
nStartPos, nSuggestedEnd, aProps);
|
||||
|
||||
//!! work-around to prevent looping if the grammar checker
|
||||
//!! failed to properly identify the sentence end
|
||||
if (aRes.nBehindEndOfSentencePosition <= nStartPos
|
||||
&& aRes.nBehindEndOfSentencePosition != nSuggestedEnd)
|
||||
{
|
||||
SAL_WARN(
|
||||
"linguistic",
|
||||
"!! Grammarchecker failed to provide end of sentence !!");
|
||||
aRes.nBehindEndOfSentencePosition = nSuggestedEnd;
|
||||
}
|
||||
|
||||
aRes.xFlatParagraph = xFlatPara;
|
||||
aRes.nStartOfSentencePosition = nStartPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
// no grammar checker -> no error
|
||||
// but we need to provide the data below in order to continue with the next sentence
|
||||
aRes.aDocumentIdentifier = aCurDocId;
|
||||
aRes.xFlatParagraph = xFlatPara;
|
||||
aRes.aText = aCurTxt;
|
||||
aRes.aLocale = aCurLocale;
|
||||
aRes.nStartOfSentencePosition = nStartPos;
|
||||
aRes.nBehindEndOfSentencePosition = nSuggestedEnd;
|
||||
}
|
||||
aRes.nStartOfNextSentencePosition
|
||||
= lcl_SkipWhiteSpaces(aCurTxt, aRes.nBehindEndOfSentencePosition);
|
||||
aRes.nBehindEndOfSentencePosition = lcl_BacktraceWhiteSpaces(
|
||||
aCurTxt, aRes.nStartOfNextSentencePosition);
|
||||
|
||||
aRes.xFlatParagraph = xFlatPara;
|
||||
aRes.nStartOfSentencePosition = nStartPos;
|
||||
//guard has to be cleared as ProcessResult calls out of this class
|
||||
}
|
||||
else
|
||||
{
|
||||
// no grammar checker -> no error
|
||||
// but we need to provide the data below in order to continue with the next sentence
|
||||
aRes.aDocumentIdentifier = aCurDocId;
|
||||
aRes.xFlatParagraph = xFlatPara;
|
||||
aRes.aText = aCurTxt;
|
||||
aRes.aLocale = aCurLocale;
|
||||
aRes.nStartOfSentencePosition = nStartPos;
|
||||
aRes.nBehindEndOfSentencePosition = nSuggestedEnd;
|
||||
}
|
||||
aRes.nStartOfNextSentencePosition = lcl_SkipWhiteSpaces( aCurTxt, aRes.nBehindEndOfSentencePosition );
|
||||
aRes.nBehindEndOfSentencePosition = lcl_BacktraceWhiteSpaces( aCurTxt, aRes.nStartOfNextSentencePosition );
|
||||
|
||||
//guard has to be cleared as ProcessResult calls out of this class
|
||||
aGuard.clear();
|
||||
ProcessResult( aRes, xFPIterator, aFPEntryItem.m_bAutomatic );
|
||||
// ---- THREAD SAFE END ----
|
||||
ProcessResult( aRes, xFPIterator, aFPEntryItem.m_bAutomatic );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user