From kde-bugs-dist Mon Mar 31 21:54:33 2003 From: David Faure Date: Mon, 31 Mar 2003 21:54:33 +0000 To: kde-bugs-dist Subject: [Bug 44227] Background Spellcheck Page update and general spellcheck problem X-MARC-Message: https://marc.info/?l=kde-bugs-dist&m=104914778103799 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. http://bugs.kde.org/show_bug.cgi?id=44227 ------- Additional Comments From faure@kde.org 2003-03-31 23:54 ------- Subject: koffice/lib/kotext CVS commit by faure: Fixed race condition that led to some words not being spellchecked. CCMAIL: 44227@bugs.kde.org M +14 -5 koBgSpellCheck.cc 1.35 --- koffice/lib/kotext/koBgSpellCheck.cc #1.34:1.35 @@ -230,4 +230,7 @@ void KoBgSpellCheck::nextParagraphNeedin if ( parag && parag->string() && parag->string()->needsSpellCheck() ) { +#ifdef DEBUG_BGSPELLCHECKING + kdDebug(32500) << "current parag " << parag << " needs checking again." <string()->setNeedsSpellCheck( false ); if ( m_bgSpell.currentTextObj ) m_bgSpell.currentTextObj->setNeedSpellCheck( false ); @@ -301,7 +302,16 @@ void KoBgSpellCheck::spellCheckNextParag kdDebug(32500) << "KoBgSpellCheck::spellCheckNextParagraph spell checking parag " << m_bgSpell.currentParag->paragId() << endl; #endif - // Now spell-check that paragraph + + // Get the text to spell-check QString text = m_bgSpell.currentParag->string()->toString(); text.remove( text.length() - 1, 1 ); // trailing space + + // Mark it as "we've read the text to be spell-checked", *before* doing it. + // This prevents race conditions: if the user modifies the text during + // the spellchecking, the new text _will_ be checked, since the bool will + // be set to true. + m_bgSpell.currentParag->string()->setNeedsSpellCheck( false ); + + // Now spell-check that paragraph m_bgSpell.kspell->check(text); } @@ -335,7 +345,6 @@ void KoBgSpellCheck::spellCheckerDone() kdDebug(32500) << "KoBgSpellCheck::spellCheckerDone" << endl; #endif - if(m_bgSpell.currentParag) - m_bgSpell.currentParag->string()->setNeedsSpellCheck( false ); if( m_bgSpell.currentTextObj && m_bgSpell.currentParag==m_bgSpell.currentTextObj->textDocument()->lastParag()) + // ### and there is no paragraph in the textobject that got the "needsSpellCheck" flag since! m_bgSpell.currentTextObj->setNeedSpellCheck(false); // Done checking the current paragraph, schedule the next one