From 6b4018014ca4dfe170d2ddab3873222acc3edcf0 Mon Sep 17 00:00:00 2001 From: David Redondo Date: Thu, 8 Feb 2024 12:35:09 +0100 Subject: [PATCH] Guard against render time query failing glGetQuery can fail (for example because of a context loss) in this case the buffer stays unmodified. In this case this is zero resulting in GLRenderTimeQuery::result() returning a negative value. Down the line this leads to a negative duration in the RenderJournal and RenderLoopPrivate::scheduleRepaint starting a timer with an amount of milliseconds bigger than what an int can hold. This will not actually start a timer but QTimer::isActive returns true resulting in no futher repaints being scheduled. BUG: 475605 FIXED-IN: 6.0 --- src/opengl/glrendertimequery.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/opengl/glrendertimequery.cpp b/src/opengl/glrendertimequery.cpp index 40dffc71bc..e299c358e1 100644 --- a/src/opengl/glrendertimequery.cpp +++ b/src/opengl/glrendertimequery.cpp @@ -56,6 +56,9 @@ std::chrono::nanoseconds GLRenderTimeQuery::result() if (m_query) { uint64_t nanos = 0; glGetQueryObjectui64v(m_query, GL_QUERY_RESULT, &nanos); + if (nanos == 0) { + return std::chrono::nanoseconds::zero(); + } return std::chrono::nanoseconds(nanos) - m_cpuStart; } else { return m_cpuEnd - m_cpuStart;