X-Git-Url: https://vaikene.ee/gitweb/pswgen09.html?a=blobdiff_plain;ds=sidebyside;f=src%2Fapps%2FFileFinder%2FEngine%2Fengine.cpp;h=bd15220e0f051fd3682be9bb036953b08c92eec8;hb=0c61450fcffcb36a6e23ca5b083c26543d956084;hp=b9fae0eddd917263fc16288bc4f2042406f5cd4a;hpb=e73fe47c7bba8066feeb68b0f1568f3ac493f50c;p=evaf
diff --git a/src/apps/FileFinder/Engine/engine.cpp b/src/apps/FileFinder/Engine/engine.cpp
index b9fae0e..bd15220 100644
--- a/src/apps/FileFinder/Engine/engine.cpp
+++ b/src/apps/FileFinder/Engine/engine.cpp
@@ -19,7 +19,6 @@
#include "engine.h"
-#include "version.h"
#include
#include
@@ -27,7 +26,6 @@
#include
VER_EXPORT_VERSION_INFO()
-Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR, eVaf::FileFinder::Engine::Module)
using namespace eVaf;
using namespace eVaf::FileFinder;
@@ -235,6 +233,13 @@ Internal::Worker::Worker(QObject * parent)
, mBusy(false)
{
setObjectName(QString("%1.Worker").arg(VER_MODULE_NAME_STR));
+
+ EVAF_INFO("%s created", qPrintable(objectName()));
+}
+
+Internal::Worker::~Worker()
+{
+ EVAF_INFO("%s destroyed", qPrintable(objectName()));
}
void Internal::Worker::cancel()
@@ -278,6 +283,9 @@ void Internal::Worker::run()
forever {
QMutexLocker lock(&mLock);
+ if (mDoTerminate)
+ break;
+
mSomethingToDo.wait(&mLock);
if (mDoTerminate)
@@ -304,8 +312,10 @@ void Internal::Worker::run()
lock.relock();
mBusy = false;
+ bool c = mDoCancel;
+ lock.unlock();
- emit finished(mDoCancel);
+ emit finished(c);
}
}
}
@@ -325,7 +335,7 @@ void Internal::Worker::recursiveSearch(QString const & path)
{
QMutexLocker l(&mLock);
if (mDoCancel)
- break;
+ return;
}
// Check for the file name to match the include filter and not the exclude filter
@@ -355,6 +365,13 @@ void Internal::Worker::recursiveSearch(QString const & path)
QByteArray buf;
while (!f.atEnd() && (includeFilterMatched <= 0 || excludeFilterMatched <= 0)) {
+ // Check for the cancel flag
+ {
+ QMutexLocker l(&mLock);
+ if (mDoCancel)
+ return;
+ }
+
/* We read ReadBufferSize bytes from the file and append to the buffer.
* We keep max 2 x ReadBufferSize bytes in the buffer and throw away the oldest
* ReadBufferSize bytes of data. Every block is checked twice, but we make sure that
@@ -388,9 +405,12 @@ void Internal::Worker::recursiveSearch(QString const & path)
{
QMutexLocker l(&mLock);
if (mDoCancel)
- break;
+ return;
}
+ if (mRxExcludeNames.isValid() && !mRxExcludeNames.isEmpty() && mRxExcludeNames.exactMatch(directory))
+ continue;
+
recursiveSearch(l + directory);
}
}