From e6f34e01f1961b02fbfc2fe670a9749a1941d4cc Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 8 May 2019 13:50:30 -0700 Subject: [PATCH] Qt: Fix some Qt display driver race conditions --- CHANGES | 1 + src/platform/qt/DisplayGL.cpp | 4 ++++ src/platform/qt/DisplayGL.h | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 8a78e543f..a79bda912 100644 --- a/CHANGES +++ b/CHANGES @@ -37,6 +37,7 @@ Other fixes: - Qt: Fix adjusting magnification in tile viewer when not fitting to window - FFmpeg: Improve initialization reliability and cleanup - Wii: Fix aspect ratio (fixes mgba.io/i/500) + - Qt: Fix some Qt display driver race conditions Misc: - GBA Savedata: EEPROM performance fixes - GBA Savedata: Automatically map 1Mbit Flash files as 1Mbit Flash diff --git a/src/platform/qt/DisplayGL.cpp b/src/platform/qt/DisplayGL.cpp index a07da6c7f..62166ec5d 100644 --- a/src/platform/qt/DisplayGL.cpp +++ b/src/platform/qt/DisplayGL.cpp @@ -37,6 +37,7 @@ DisplayGL::DisplayGL(const QGLFormat& format, QWidget* parent) m_painter = new PainterGL(format.majorVersion() < 2 ? 1 : m_gl->format().majorVersion(), m_gl); m_gl->setMouseTracking(true); m_gl->setAttribute(Qt::WA_TransparentForMouseEvents); // This doesn't seem to work? + setUpdatesEnabled(false); // Prevent paint events, which can cause race conditions } DisplayGL::~DisplayGL() { @@ -219,6 +220,9 @@ PainterGL::PainterGL(int majorVersion, QGLWidget* parent) #endif m_backend->swap = [](VideoBackend* v) { PainterGL* painter = static_cast(v->user); + if (!painter->m_gl->isVisible()) { + return; + } painter->m_gl->swapBuffers(); }; diff --git a/src/platform/qt/DisplayGL.h b/src/platform/qt/DisplayGL.h index 85d4ee08e..fbf44a547 100644 --- a/src/platform/qt/DisplayGL.h +++ b/src/platform/qt/DisplayGL.h @@ -32,7 +32,7 @@ public: EmptyGLWidget(const QGLFormat& format, QWidget* parent) : QGLWidget(format, parent) { setAutoBufferSwap(false); } protected: - void paintEvent(QPaintEvent*) override {} + void paintEvent(QPaintEvent* event) override { event->ignore(); } void resizeEvent(QResizeEvent*) override {} void mouseMoveEvent(QMouseEvent* event) override { event->ignore(); } };