Skip to content

Commit f0a9f1e

Browse files
committed
add Mutex for cancel anaylsis action
1 parent caa54a2 commit f0a9f1e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

analysis/analysisrunner.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void AnalysisRunner::run()
118118
a->before();
119119

120120

121-
while (reader.next() && !mCancel)
121+
while (reader.next() && !isCanceled())
122122
{
123123

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

218218
void AnalysisRunner::cancel()
219219
{
220+
QMutexLocker locker(&mMutex);
220221
mCancel = true;
221222
mStatus = Canceled;
222223
}
223224

225+
bool AnalysisRunner::isCanceled()
226+
{
227+
QMutexLocker locker(&mMutex);
228+
return mCancel;
229+
}
230+
224231
qint64 AnalysisRunner::fileSize() const
225232
{
226233
return mFileSize;

analysis/analysisrunner.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class AnalysisRunner : public QRunnable
8989
int sequenceCount() const;
9090

9191
void cancel();
92+
bool isCanceled();
9293

9394
qint64 fileSize() const;
9495

@@ -127,6 +128,7 @@ class AnalysisRunner : public QRunnable
127128
int mDuration = 0;
128129
Status mStatus = Waiting;
129130
bool mCancel = false;
131+
QMutex mMutex;
130132

131133

132134

0 commit comments

Comments
 (0)