Skip to content

Commit

Permalink
add Mutex for cancel anaylsis action
Browse files Browse the repository at this point in the history
  • Loading branch information
dridk committed Apr 22, 2017
1 parent caa54a2 commit f0a9f1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion analysis/analysisrunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void AnalysisRunner::run()
a->before();


while (reader.next() && !mCancel)
while (reader.next() && !isCanceled())
{

// check if first sequence is valid..Means it's probably a good file
Expand Down Expand Up @@ -217,10 +217,17 @@ int AnalysisRunner::sequenceCount() const

void AnalysisRunner::cancel()
{
QMutexLocker locker(&mMutex);
mCancel = true;
mStatus = Canceled;
}

bool AnalysisRunner::isCanceled()
{
QMutexLocker locker(&mMutex);
return mCancel;
}

qint64 AnalysisRunner::fileSize() const
{
return mFileSize;
Expand Down
2 changes: 2 additions & 0 deletions analysis/analysisrunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class AnalysisRunner : public QRunnable
int sequenceCount() const;

void cancel();
bool isCanceled();

qint64 fileSize() const;

Expand Down Expand Up @@ -127,6 +128,7 @@ class AnalysisRunner : public QRunnable
int mDuration = 0;
Status mStatus = Waiting;
bool mCancel = false;
QMutex mMutex;



Expand Down

0 comments on commit f0a9f1e

Please sign in to comment.