From 5e59fcd0f441ebdc204d9816f7d88c7218ddb7ff Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Fri, 21 Jan 2022 16:10:07 -0500 Subject: Reimplement progresstask with std::condition_variable --- ui/progresstask.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ui/progresstask.h b/ui/progresstask.h index a291c439..009e2c67 100644 --- a/ui/progresstask.h +++ b/ui/progresstask.h @@ -88,13 +88,21 @@ class BINARYNINJAUIAPI ProgressTask: public QObject { Q_OBJECT - std::atomic_bool m_canceled; ProgressDialog* m_dialog; std::function)> m_func; - QThread* m_thread; + std::thread m_thread; + std::mutex m_mutex; + std::condition_variable m_cv; + bool m_canceled; + bool m_finished; std::exception_ptr m_exception; + /*! + Run the task function (called on the background thread) + */ + void start(); + public: /*! Construct a new progress task, which automatically starts running a given function @@ -135,11 +143,6 @@ public: */ void setText(const QString& text); -private Q_SLOTS: - void start(); - - void finish(); - public Q_SLOTS: /*! Cancel the progress dialog -- cgit v1.3.1