From 6ad33e1ff7618704fd41549780d0d0c93778364e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 17 Nov 2010 13:01:38 +0100 Subject: Prevent crash in GL 2 engine when stroking null rectangle. Task-number: QTBUG-15320 Reviewed-by: Kim --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 3 +++ tests/auto/qgl/tst_qgl.cpp | 23 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 73915cb..37552ac 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1212,6 +1212,9 @@ void QGL2PaintEngineExPrivate::stroke(const QVectorPath &path, const QPen &pen) stroker.process(dashStroke, pen, clip); } + if (!stroker.vertexCount()) + return; + if (opaque) { prepareForDraw(opaque); setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, stroker.vertices()); diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index e38bf42..cc2cac9 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -97,6 +97,7 @@ private slots: void qglContextDefaultBindTexture(); void textureCleanup(); void threadImages(); + void nullRectCrash(); }; tst_QGL::tst_QGL() @@ -2375,6 +2376,28 @@ void tst_QGL::threadImages() delete widget; } +void tst_QGL::nullRectCrash() +{ + if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()) + QSKIP("QGLFramebufferObject not supported on this platform", SkipSingle); + + QGLWidget glw; + glw.makeCurrent(); + + QGLFramebufferObjectFormat fboFormat; + fboFormat.setAttachment(QGLFramebufferObject::CombinedDepthStencil); + + QGLFramebufferObject *fbo = new QGLFramebufferObject(128, 128, fboFormat); + + QPainter fboPainter(fbo); + + fboPainter.setPen(QPen(QColor(255, 127, 127, 127), 2)); + fboPainter.setBrush(QColor(127, 255, 127, 127)); + fboPainter.drawRect(QRectF()); + + fboPainter.end(); +} + class tst_QGLDummy : public QObject { Q_OBJECT -- cgit v0.12