From 8c257264c1873dcf11115d738f9510c1b65da844 Mon Sep 17 00:00:00 2001
From: Andy Nichols <andy.nichols@digia.com>
Date: Tue, 14 Oct 2014 15:31:05 +0200
Subject: [PATCH] QQuickCustomParticle: Check for current OpenGL Context before
 use

QQuickCustomParticle::buildCustomNodes() assumes there is a valid OpenGL
context, but when there is not it will simply crash.  Instead we check
for a valid current OpenGL context first, and return 0 if it is not
availalbe.  This needed for the Qt Quick 2d Renderer.

Change-Id: I6bfcfc8fa9581bfd27015f719fc527c36492eade
Reviewed-by: aavit <eirik.aavitsland@digia.com>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
---
 src/particles/qquickcustomparticle.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/particles/qquickcustomparticle.cpp b/src/particles/qquickcustomparticle.cpp
index e03acd693a..2ab24175a3 100644
--- a/src/particles/qquickcustomparticle.cpp
+++ b/src/particles/qquickcustomparticle.cpp
@@ -303,6 +303,9 @@ QQuickShaderEffectNode *QQuickCustomParticle::prepareNextFrame(QQuickShaderEffec
 
 QQuickShaderEffectNode* QQuickCustomParticle::buildCustomNodes()
 {
+    if (!QOpenGLContext::currentContext())
+        return 0;
+
     if (QOpenGLContext::currentContext()->isOpenGLES() && m_count * 4 > 0xffff) {
         printf("CustomParticle: Too many particles... \n");
         return 0;
-- 
GitLab