summaryrefslogtreecommitdiffstats
path: root/job.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'job.cpp')
-rw-r--r--job.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/job.cpp b/job.cpp
index bbc55b4..cba2507 100644
--- a/job.cpp
+++ b/job.cpp
@@ -5,7 +5,8 @@
Job::Job(Video *parent, bool threaded)
: QObject(parent),
m_gui(0),
- m_video(parent)
+ m_video(parent),
+ m_terminated(false)
{
if (threaded) {
m_watcher = new QFutureWatcher<bool>;
@@ -20,6 +21,7 @@ Video* Job::video() const
}
void Job::runJob()
{
+ m_terminated = false;
if (m_watcher)
m_watcher->setFuture(QtConcurrent::run(this, &Job::executeJob));
else
@@ -27,7 +29,8 @@ void Job::runJob()
}
void Job::jobFinished()
{
- emit completed(m_watcher->future().result());
+ if (!m_terminated)
+ emit completed(m_watcher->future().result());
}
QWidget* Job::widget()
{
@@ -39,3 +42,13 @@ QFutureWatcher<bool>* Job::watcher() const
{
return m_watcher;
}
+void Job::terminate()
+{
+ m_terminated = true;
+ kill();
+ emit completed(false);
+}
+bool Job::terminated() const
+{
+ return m_terminated;
+}