From b17814e6ffcd048da7562d62ecad1bc38db7d980 Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Wed, 2 May 2012 10:10:39 +0100 Subject: Allow creation of QOpenGLShaderProgram without a current context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change prevents the qWarning() in QOpenGLFunctions from being triggered when creating a QOpenGLShaderProgram object without a current QOpenGLContext. This is a common case especially when the shader program is a member variable of a class. It now relies upon the QOpenGLShaderProgram::init() function to resolve the GL function pointers when the shader program is first used which of course should be done with an active context. Change-Id: Ib7dc345593f2a70d72ef8f650151cc90001058ca Reviewed-by: Samuel Rødal --- src/gui/opengl/qopenglshaderprogram.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gui/opengl/qopenglshaderprogram.cpp') diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp index 8ee2928a1fd..c0899e5a411 100644 --- a/src/gui/opengl/qopenglshaderprogram.cpp +++ b/src/gui/opengl/qopenglshaderprogram.cpp @@ -510,7 +510,7 @@ class QOpenGLShaderProgramPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QOpenGLShaderProgram) public: - QOpenGLShaderProgramPrivate(QOpenGLContext *ctx) + QOpenGLShaderProgramPrivate() : programGuard(0) , linked(false) , inited(false) @@ -518,7 +518,7 @@ public: , geometryVertexCount(64) , geometryInputType(0) , geometryOutputType(0) - , glfuncs(new QOpenGLFunctions(ctx)) + , glfuncs(new QOpenGLFunctions) { } ~QOpenGLShaderProgramPrivate(); @@ -574,7 +574,7 @@ bool QOpenGLShaderProgramPrivate::hasShader(QOpenGLShader::ShaderType type) cons \sa addShader() */ QOpenGLShaderProgram::QOpenGLShaderProgram(QObject *parent) - : QObject(*new QOpenGLShaderProgramPrivate(QOpenGLContext::currentContext()), parent) + : QObject(*new QOpenGLShaderProgramPrivate, parent) { } -- cgit v1.2.3