all repos — mgba @ 8a9a8859a68b8abdc2632cfe9dcf3b91a281f685

mGBA Game Boy Advance Emulator

Qt: Display memory cleanup
Vicki Pfau vi@endrift.com
Fri, 31 Jul 2020 01:31:49 -0700
commit

8a9a8859a68b8abdc2632cfe9dcf3b91a281f685

parent

8ee4b3c0463ad402aa60e5c9f406da812952f9a0

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

jump to
M src/platform/qt/DisplayGL.cppsrc/platform/qt/DisplayGL.cpp

@@ -327,18 +327,12 @@ m_backend->filter = false;

m_backend->lockAspectRatio = false; m_backend->interframeBlending = false; - for (int i = 0; i < 3; ++i) { - m_free.append(new uint32_t[1024 * 2048]); + for (auto& buf : m_buffers) { + m_free.append(&buf.front()); } } PainterGL::~PainterGL() { - while (!m_queue.isEmpty()) { - delete[] m_queue.dequeue(); - } - for (auto item : m_free) { - delete[] item; - } m_gl->makeCurrent(m_surface); #if defined(_WIN32) && defined(USE_EPOXY) epoxy_handle_external_wglMakeCurrent();
M src/platform/qt/DisplayGL.hsrc/platform/qt/DisplayGL.h

@@ -25,6 +25,8 @@ #include <QQueue>

#include <QThread> #include <QTimer> +#include <array> + #include "VideoProxy.h" #include "platform/video-backend.h"

@@ -119,6 +121,7 @@ void performDraw();

void dequeue(); void dequeueAll(); + std::array<std::array<uint32_t, 0x100000>, 3> m_buffers; QList<uint32_t*> m_free; QQueue<uint32_t*> m_queue; uint32_t* m_buffer;