[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KOFFICE_1_2_BRANCH: koffice/lib/kotext
From:       David Faure <faure () kde ! org>
Date:       2003-03-31 21:54:34
[Download RAW message or body]

CVS commit by faure: 

Backport race condition fix


  M +14 -5     koBgSpellCheck.cc   1.31.2.3


--- koffice/lib/kotext/koBgSpellCheck.cc  #1.31.2.2:1.31.2.3
@@ -222,4 +222,7 @@ void KoBgSpellCheck::nextParagraphNeedin
     if ( parag && parag->string() && parag->string()->needsSpellCheck() )
     {
+#ifdef DEBUG_BGSPELLCHECKING
+        kdDebug(32500) << "current parag " << parag << " needs checking again." \
<<endl; +#endif
         return;
     }
@@ -253,6 +256,4 @@ void KoBgSpellCheck::nextParagraphNeedin
         else
         {
-            if ( m_bgSpell.currentParag )
-                m_bgSpell.currentParag->string()->setNeedsSpellCheck( false );
             if ( m_bgSpell.currentTextObj )
                 m_bgSpell.currentTextObj->setNeedSpellCheck( false );
@@ -293,7 +294,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);
 }
@@ -327,7 +337,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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic