From 9ebd76b0214730bfa184008e0a5b2541827912eb Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 11 Oct 2013 17:59:50 +0200 Subject: Avoid calling convertFromGLImage on a null image. Task-number: QTBUG-34017 Change-Id: If51ef4b1f906677e26d14b5a92799097d18ac437 Reviewed-by: Laszlo Agocs --- src/opengl/qgl.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index c96200fe1b..8ee0a8b290 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1638,6 +1638,7 @@ QGLContext* QGLContext::currentCtx = 0; static void convertFromGLImage(QImage &img, int w, int h, bool alpha_format, bool include_alpha) { + Q_ASSERT(!img.isNull()); if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { // OpenGL gives RGBA; Qt wants ARGB uint *p = (uint*)img.bits(); @@ -1682,6 +1683,8 @@ QImage qt_gl_read_frame_buffer(const QSize &size, bool alpha_format, bool includ { QImage img(size, (alpha_format && include_alpha) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); + if (img.isNull()) + return QImage(); int w = size.width(); int h = size.height(); glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, img.bits()); @@ -1692,6 +1695,8 @@ QImage qt_gl_read_frame_buffer(const QSize &size, bool alpha_format, bool includ QImage qt_gl_read_texture(const QSize &size, bool alpha_format, bool include_alpha) { QImage img(size, alpha_format ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); + if (img.isNull()) + return QImage(); int w = size.width(); int h = size.height(); #if !defined(QT_OPENGL_ES_2) -- cgit v1.2.3