all repos — mgba @ 6d40d174a81c9bda7447e3b76e0f8cb2598cbd9a

mGBA Game Boy Advance Emulator

Qt: Attempt to fix DisplayGL crash
Vicki Pfau vi@endrift.com
Fri, 31 Jul 2020 01:33:47 -0700
commit

6d40d174a81c9bda7447e3b76e0f8cb2598cbd9a

parent

8fabac962e641fa50f46c9768fbd55952e14bbe2

2 files changed, 8 insertions(+), 12 deletions(-)

jump to
M CHANGESCHANGES

@@ -25,6 +25,7 @@ - GBA Savedata: Fix extracting save when not yet configured in-game

- Qt: Fix file handle leak on opening an invalid ROM - Qt: Fix Italian RTC translation (fixes mgba.io/i/1798) - Qt: Add missing option for Wisdom Tree in overrides list + - Qt: Fix stability regression on AMD drivers (fixes mgba.io/i/1791) - Util: Fix crash if PNG header fails to write - Wii: Fix pixelated filtering on interframe blending (fixes mgba.io/i/1830) Misc:
M src/platform/qt/DisplayGL.cppsrc/platform/qt/DisplayGL.cpp

@@ -484,8 +484,6 @@ float r = m_surface->devicePixelRatio();

m_backend->resized(m_backend, m_size.width() * r, m_size.height() * r); if (m_buffer) { m_backend->postFrame(m_backend, m_buffer); - m_free.append(m_buffer); - m_buffer = nullptr; } m_backend->drawFrame(m_backend); m_painter.endNativePainting();

@@ -495,7 +493,7 @@ }

} void PainterGL::enqueue(const uint32_t* backing) { - m_mutex.lock(); + QMutexLocker locker(&m_mutex); uint32_t* buffer = nullptr; if (backing) { if (m_free.isEmpty()) {

@@ -503,17 +501,17 @@ buffer = m_queue.dequeue();

} else { buffer = m_free.takeLast(); } - QSize size = m_context->screenDimensions(); - memcpy(buffer, backing, size.width() * size.height() * BYTES_PER_PIXEL); + if (buffer) { + QSize size = m_context->screenDimensions(); + memcpy(buffer, backing, size.width() * size.height() * BYTES_PER_PIXEL); + } } m_queue.enqueue(buffer); - m_mutex.unlock(); } void PainterGL::dequeue() { - m_mutex.lock(); + QMutexLocker locker(&m_mutex); if (m_queue.isEmpty()) { - m_mutex.unlock(); return; } uint32_t* buffer = m_queue.dequeue();

@@ -521,10 +519,7 @@ if (m_buffer) {

m_free.append(m_buffer); m_buffer = nullptr; } - if (buffer) { - m_buffer = buffer; - } - m_mutex.unlock(); + m_buffer = buffer; } void PainterGL::dequeueAll() {