Avoid crashing in QOpenGLWidget::metrics
When creating child widgets in the derived class' constructor, the screen cannot be retrieved via window() since it still returns null. Handle this case properly. Change-Id: I65bf7f9c338ce8a3ddab8ad7886cfe2f1f253c82 Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
This commit is contained in:
parent
1b1dd22486
commit
e79f008ae5
@ -867,7 +867,8 @@ int QOpenGLWidget::metric(QPaintDevice::PaintDeviceMetric metric) const
|
||||
if (d->inBackingStorePaint)
|
||||
return QWidget::metric(metric);
|
||||
|
||||
QScreen *screen = window()->windowHandle()->screen();
|
||||
QWidget *tlw = window();
|
||||
QScreen *screen = tlw && tlw->windowHandle() ? tlw->windowHandle()->screen() : 0;
|
||||
if (!screen && QGuiApplication::primaryScreen())
|
||||
screen = QGuiApplication::primaryScreen();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user