Fix Qt's texture use-after-free with HiDPI

This commit is contained in:
Ilya Fedin 2023-12-06 02:48:50 +04:00 committed by John Preston
parent a8b24e6f6f
commit 367a64aa1f

View file

@ -38,7 +38,6 @@ private:
const std::unique_ptr<Renderer> _renderer; const std::unique_ptr<Renderer> _renderer;
QMetaObject::Connection _connection; QMetaObject::Connection _connection;
QSize _deviceSize; QSize _deviceSize;
bool _inPaintEvent = false;
}; };
@ -85,16 +84,10 @@ void SurfaceOpenGL::resizeGL(int w, int h) {
} }
void SurfaceOpenGL::paintEvent(QPaintEvent *e) { void SurfaceOpenGL::paintEvent(QPaintEvent *e) {
if (_inPaintEvent) {
return;
}
_inPaintEvent = true;
if (_deviceSize != size() * devicePixelRatio()) { if (_deviceSize != size() * devicePixelRatio()) {
QResizeEvent event = { size(), size() }; QCoreApplication::postEvent(this, new QResizeEvent(size(), size()));
resizeEvent(&event);
} }
QOpenGLWidget::paintEvent(e); QOpenGLWidget::paintEvent(e);
_inPaintEvent = false;
} }
void SurfaceOpenGL::paintGL() { void SurfaceOpenGL::paintGL() {