diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-10-12 22:18:04 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-11-07 19:25:24 +0200 |
commit | 4b9a774a4c1c5fbefd056f2d1f617b657b7238b5 (patch) | |
tree | 1c37901ed75f8dcbf63b024d1a93ceebf1676e5e /src/qcam/viewfinder_gl.h | |
parent | af2e36fc1bb87a8ce913ec7160aa7a6ed7d3c59b (diff) |
qcam: viewfinder_gl: Fix fragment shader rebuild when setting format
When setting a new format, the existing fragment shader is deleted and a
new shader should be created. However, the shader pointer isn't set to
nullptr after deleting it, resulting in the deleter shader being reused.
Fix it by managing shader pointers with std::unique_ptr<> to prevent
similar bugs from happening in the future.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/qcam/viewfinder_gl.h')
-rw-r--r-- | src/qcam/viewfinder_gl.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/qcam/viewfinder_gl.h b/src/qcam/viewfinder_gl.h index ad1e195e..40c04dc5 100644 --- a/src/qcam/viewfinder_gl.h +++ b/src/qcam/viewfinder_gl.h @@ -8,6 +8,8 @@ #ifndef __VIEWFINDER_GL_H__ #define __VIEWFINDER_GL_H__ +#include <memory> + #include <QImage> #include <QMutex> #include <QOpenGLBuffer> @@ -67,8 +69,8 @@ private: /* Shaders */ QOpenGLShaderProgram shaderProgram_; - QOpenGLShader *vertexShader_; - QOpenGLShader *fragmentShader_; + std::unique_ptr<QOpenGLShader> vertexShader_; + std::unique_ptr<QOpenGLShader> fragmentShader_; QString fragmentShaderFile_; QStringList fragmentShaderDefines_; |