diff options
author | David Boddie <dboddie@trolltech.com> | 2009-08-31 12:07:01 (GMT) |
---|---|---|
committer | David Boddie <dboddie@trolltech.com> | 2009-08-31 12:07:01 (GMT) |
commit | ef12918fed8c046abcb3e527cc31440b59a50c17 (patch) | |
tree | 7a2551688262ed460e2c709c4ec63c0c1f4df853 /src/opengl/qglshaderprogram.cpp | |
parent | 1fc237371f98672854331e5855de4d9af2586a51 (diff) | |
parent | 52c8038b3c8eb8974a7740f42326b27b32416bc4 (diff) | |
download | Qt-ef12918fed8c046abcb3e527cc31440b59a50c17.zip Qt-ef12918fed8c046abcb3e527cc31440b59a50c17.tar.gz Qt-ef12918fed8c046abcb3e527cc31440b59a50c17.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'src/opengl/qglshaderprogram.cpp')
-rw-r--r-- | src/opengl/qglshaderprogram.cpp | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index b07fb3b..88e8fb0 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -9,8 +9,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,20 +21,20 @@ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this ** package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -701,6 +701,7 @@ public: , linked(false) , inited(false) , hasPartialShaders(false) + , removingShaders(false) , vertexShader(0) , fragmentShader(0) { @@ -716,6 +717,7 @@ public: bool linked; bool inited; bool hasPartialShaders; + bool removingShaders; QString log; QList<QGLShader *> shaders; QList<QGLShader *> anonShaders; @@ -813,6 +815,7 @@ bool QGLShaderProgram::addShader(QGLShader *shader) } d->linked = false; // Program needs to be relinked. d->shaders.append(shader); + connect(shader, SIGNAL(destroyed()), this, SLOT(shaderDestroyed())); return true; } else { return false; @@ -917,12 +920,14 @@ bool QGLShaderProgram::addShaderFromFile */ void QGLShaderProgram::removeShader(QGLShader *shader) { - if (d->program && shader && shader->d->shader) { + if (d->program && shader && shader->d->shader) glDetachShader(d->program, shader->d->shader); - d->linked = false; // Program needs to be relinked. + d->linked = false; // Program needs to be relinked. + if (shader) { + d->shaders.removeAll(shader); + d->anonShaders.removeAll(shader); + disconnect(shader, SIGNAL(destroyed()), this, SLOT(shaderDestroyed())); } - d->shaders.removeAll(shader); - d->anonShaders.removeAll(shader); } /*! @@ -946,6 +951,7 @@ QList<QGLShader *> QGLShaderProgram::shaders() const */ void QGLShaderProgram::removeAllShaders() { + d->removingShaders = true; foreach (QGLShader *shader, d->shaders) { if (d->program && shader && shader->d->shader) glDetachShader(d->program, shader->d->shader); @@ -957,6 +963,7 @@ void QGLShaderProgram::removeAllShaders() d->shaders.clear(); d->anonShaders.clear(); d->linked = false; // Program needs to be relinked. + d->removingShaders = false; } #if defined(QT_OPENGL_ES_2) @@ -2977,6 +2984,15 @@ bool QGLShaderProgram::hasShaderPrograms(const QGLContext *context) #endif } +/*! + \internal +*/ +void QGLShaderProgram::shaderDestroyed() +{ + QGLShader *shader = qobject_cast<QGLShader *>(sender()); + if (shader && !d->removingShaders) + removeShader(shader); +} #endif |