diff --git a/addon.cpp b/addon.cpp index 9e09c1d..ba140f8 100644 --- a/addon.cpp +++ b/addon.cpp @@ -503,6 +503,7 @@ void Addon::openRepo() void Addon::delegate(QString taskname, auto work, auto callback) { + Q_ASSERT_X(QThread::currentThread() == thread(), "delegate", "Attempt to delegate from another thread."); if (status() != Status::Ready) { qInfo() << name() << "Enqueueing" << taskname; m_tasks.enqueue({taskname, [this, taskname, work, callback](){delegate(taskname, work,callback);}}); @@ -525,8 +526,7 @@ void Addon::delegate(QString taskname, auto work, auto callback) else callback(fw->result()); - while(!old.isEmpty()) - m_tasks.enqueue(old.dequeue()); + m_tasks.append(old); if (!m_tasks.isEmpty() && status() != Status::Busy) m_tasks.dequeue().second(); diff --git a/control.cpp b/control.cpp index 482402a..f0f0375 100644 --- a/control.cpp +++ b/control.cpp @@ -39,6 +39,7 @@ Control::Control(QObject *parent) : QObject(parent), m_progress(0), m_total(0), void Control::delegate(QString taskname, auto work, auto callback) { + Q_ASSERT_X(QThread::currentThread() == thread(), "delegate", "Attempt to delegate from another thread."); if (status() != Status::Ready) { qInfo() << "Enqueueing" << taskname; m_tasks.enqueue({taskname, [this, taskname, work, callback](){delegate(taskname, work,callback);}}); @@ -62,8 +63,7 @@ void Control::delegate(QString taskname, auto work, auto callback) else callback(fw->result()); - while(!old.isEmpty()) - m_tasks.enqueue(old.dequeue()); + m_tasks.append(old); if (!m_tasks.isEmpty() && status() != Status::Busy) m_tasks.dequeue().second();