From 8a375abe418e2c58cbfb2e959352807cad26de15 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 12 Oct 2016 16:51:29 +0200 Subject: [PATCH] Add self-deletion and waiting to LambdaThread --- qrenderdoc/Code/CaptureContext.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qrenderdoc/Code/CaptureContext.h b/qrenderdoc/Code/CaptureContext.h index 14c7a3d94..189f339ed 100644 --- a/qrenderdoc/Code/CaptureContext.h +++ b/qrenderdoc/Code/CaptureContext.h @@ -239,6 +239,7 @@ private: std::function m_func; QThread *m_Thread; QSemaphore completed; + bool m_SelfDelete = false; public slots: void process() @@ -247,9 +248,12 @@ public slots: m_Thread->quit(); m_Thread->deleteLater(); m_Thread = NULL; + if(m_SelfDelete) + deleteLater(); completed.acquire(); } + void selfDelete(bool d) { m_SelfDelete = d; } public: explicit LambdaThread(std::function f) { @@ -262,6 +266,12 @@ public: void start(QThread::Priority prio = QThread::InheritPriority) { m_Thread->start(prio); } bool isRunning() { return completed.available(); } + bool wait(unsigned long time = ULONG_MAX) + { + if(m_Thread) + return m_Thread->wait(time); + return true; + } }; class QMenu;