summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElvis Angelaccio <elvis.angelaccio@kde.org>2016-09-13 13:55:21 (GMT)
committerElvis Angelaccio <elvis.angelaccio@kde.org>2016-09-13 14:08:08 (GMT)
commit0fffb96407b5ca9c297c092f34a333a1717f4bd9 (patch)
tree6878c570b89ed171b541a9e2e484cb1ab7f1ff60
parentd050af5c25392da576bd05228d731db17f9d5e93 (diff)
Drop unused event loop code
The event loop in the QThread's run() method was only necessary when CliInterface was running in another thread, but this is no longer happening. This event loop does not even start because when doWork() returns, `result` has already been emitted, resulting in q->isRunning() being false. This also means that we can drop m_isRunning, removing a possible source of race conditions.
-rw-r--r--kerfuffle/jobs.cpp24
-rw-r--r--kerfuffle/jobs.h4
2 files changed, 0 insertions, 28 deletions
diff --git a/kerfuffle/jobs.cpp b/kerfuffle/jobs.cpp
index c4feeab..1e396f1 100644
--- a/kerfuffle/jobs.cpp
+++ b/kerfuffle/jobs.cpp
@@ -39,8 +39,6 @@
#include <KLocalizedString>
-//#define DEBUG_RACECONDITION
-
namespace Kerfuffle
{
@@ -51,7 +49,6 @@ public:
: QThread(parent)
, q(job)
{
- connect(q, &KJob::result, this, &QThread::quit);
}
virtual void run() Q_DECL_OVERRIDE;
@@ -63,20 +60,11 @@ private:
void Job::Private::run()
{
q->doWork();
-
- if (q->isRunning()) {
- exec();
- }
-
-#ifdef DEBUG_RACECONDITION
- QThread::sleep(2);
-#endif
}
Job::Job(ReadOnlyArchiveInterface *interface)
: KJob()
, m_archiveInterface(interface)
- , m_isRunning(false)
, d(new Private(this))
{
static bool onlyOnce = false;
@@ -105,15 +93,9 @@ ReadOnlyArchiveInterface *Job::archiveInterface()
return m_archiveInterface;
}
-bool Job::isRunning() const
-{
- return m_isRunning;
-}
-
void Job::start()
{
jobTimer.start();
- m_isRunning = true;
if (archiveInterface()->waitForFinishedSignal()) {
// CLI-based interfaces run a QProcess, no need to use threads.
@@ -124,12 +106,6 @@ void Job::start()
}
}
-void Job::emitResult()
-{
- m_isRunning = false;
- KJob::emitResult();
-}
-
void Job::connectToArchiveInterfaceSignals()
{
connect(archiveInterface(), &ReadOnlyArchiveInterface::cancelled, this, &Job::onCancelled);
diff --git a/kerfuffle/jobs.h b/kerfuffle/jobs.h
index 196b0bf..da25e9a 100644
--- a/kerfuffle/jobs.h
+++ b/kerfuffle/jobs.h
@@ -50,13 +50,10 @@ class KERFUFFLE_EXPORT Job : public KJob
public:
void start();
- bool isRunning() const;
-
protected:
Job(ReadOnlyArchiveInterface *interface);
virtual ~Job();
virtual bool doKill();
- virtual void emitResult();
ReadOnlyArchiveInterface *archiveInterface();
QList<Archive::Entry*> m_archiveEntries;
@@ -85,7 +82,6 @@ signals:
private:
ReadOnlyArchiveInterface *m_archiveInterface;
- bool m_isRunning;
QElapsedTimer jobTimer;
class Private;