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:
Laszlo Agocs 2014-08-06 12:29:00 +02:00
parent 1b1dd22486
commit e79f008ae5

View File

@ -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();