From 880c91320a8295df0c47fc754b03121370c80d43 Mon Sep 17 00:00:00 2001 From: EndrII Date: Tue, 28 Jan 2025 15:46:52 +0100 Subject: [PATCH] fix render loop run and stop functions --- src/public/asyncrenderloop.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/public/asyncrenderloop.cpp b/src/public/asyncrenderloop.cpp index 517d29a..6eb26c2 100644 --- a/src/public/asyncrenderloop.cpp +++ b/src/public/asyncrenderloop.cpp @@ -20,11 +20,16 @@ AsyncRenderLoop::~AsyncRenderLoop() { } void QH::AsyncRenderLoop::run() { - m_run = true; - asyncLauncher([this](){ - renderLoopPrivate(); - return true; - }); + if (auto && thrd = thread()) { + m_run = true; + thrd->start(); + + asyncLauncher([this](){ + renderLoopPrivate(); + return true; + }); + } + } void QH::AsyncRenderLoop::stop() { @@ -34,7 +39,7 @@ void QH::AsyncRenderLoop::stop() { } bool AsyncRenderLoop::isRun() const { - return m_run || (thread() && thread()->isRunning()); + return m_run && (thread() && thread()->isRunning()); } void QH::AsyncRenderLoop::renderLoopPrivate() {