From 367a64aa1f8fdb474580489345110c8ac394ae49 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 6 Dec 2023 02:48:50 +0400 Subject: [PATCH] Fix Qt's texture use-after-free with HiDPI --- ui/gl/gl_surface.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/ui/gl/gl_surface.cpp b/ui/gl/gl_surface.cpp index 3900b07..64f3bcb 100644 --- a/ui/gl/gl_surface.cpp +++ b/ui/gl/gl_surface.cpp @@ -38,7 +38,6 @@ private: const std::unique_ptr _renderer; QMetaObject::Connection _connection; QSize _deviceSize; - bool _inPaintEvent = false; }; @@ -85,16 +84,10 @@ void SurfaceOpenGL::resizeGL(int w, int h) { } void SurfaceOpenGL::paintEvent(QPaintEvent *e) { - if (_inPaintEvent) { - return; - } - _inPaintEvent = true; if (_deviceSize != size() * devicePixelRatio()) { - QResizeEvent event = { size(), size() }; - resizeEvent(&event); + QCoreApplication::postEvent(this, new QResizeEvent(size(), size())); } QOpenGLWidget::paintEvent(e); - _inPaintEvent = false; } void SurfaceOpenGL::paintGL() {