all repos — mgba @ 8fdfa130bd717f141a35dc77d6e724ba0c00c65e

mGBA Game Boy Advance Emulator

Qt: Fix DisplayGL crash
Vicki Pfau vi@endrift.com
Thu, 05 Jul 2018 20:26:03 -0700
commit

8fdfa130bd717f141a35dc77d6e724ba0c00c65e

parent

08ec1e89c41606c5ae99005aaf665d1d4e254f56

1 files changed, 7 insertions(+), 2 deletions(-)

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

@@ -29,8 +29,11 @@ using namespace QGBA;

DisplayGL::DisplayGL(const QGLFormat& format, QWidget* parent) : Display(parent) - , m_gl(new EmptyGLWidget(format, this)) + , m_gl(nullptr) { + // This can spontaneously re-enter into this->resizeEvent before creation is done, so we + // need to make sure it's initialized to nullptr before we assign the new object to it + m_gl = new EmptyGLWidget(format, this); 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?

@@ -162,7 +165,9 @@ resizePainter();

} void DisplayGL::resizePainter() { - m_gl->resize(size()); + if (m_gl) { + m_gl->resize(size()); + } if (m_drawThread) { QMetaObject::invokeMethod(m_painter, "resize", Qt::BlockingQueuedConnection, Q_ARG(QSize, size())); }