diff --git a/src/wordfinder.cc b/src/wordfinder.cc index e2dcc748e..b200ac3d5 100644 --- a/src/wordfinder.cc +++ b/src/wordfinder.cc @@ -4,6 +4,7 @@ #include "wordfinder.hh" #include "folding.hh" #include +#include using std::vector; @@ -112,6 +113,7 @@ void WordFinder::startSearch() return; // Search was probably cancelled } + QMutexLocker locker( &mutex ); // Clear the requests just in case queuedRequests.clear(); finishedRequests.clear(); @@ -177,6 +179,7 @@ void WordFinder::cancel() void WordFinder::clear() { + QMutexLocker locker( &mutex ); cancel(); queuedRequests.clear(); finishedRequests.clear(); @@ -184,6 +187,7 @@ void WordFinder::clear() void WordFinder::requestFinished() { + QMutexLocker locker( &mutex ); bool newResults = false; // See how many new requests have finished, and if we have any new results @@ -288,6 +292,7 @@ void WordFinder::updateResults() if ( updateResultsTimer.isActive() ) { updateResultsTimer.stop(); // Can happen when we were done before it'd expire } + QMutexLocker locker( &mutex ); std::u32string original = Folding::applySimpleCaseOnly( allWordWritings[ 0 ] ); diff --git a/src/wordfinder.hh b/src/wordfinder.hh index 189d80985..1165b7bfb 100644 --- a/src/wordfinder.hh +++ b/src/wordfinder.hh @@ -30,6 +30,7 @@ private: bool searchResultsUncertain; std::list< sptr< Dictionary::WordSearchRequest > > queuedRequests, finishedRequests; bool searchInProgress; + QMutex mutex; QTimer updateResultsTimer;