summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Krause <volker.krause@kdab.com>2016-01-08 11:04:00 +0100
committerVolker Krause <volker.krause@kdab.com>2016-01-19 13:16:06 +0000
commit4d70b9af0049562cfb8cc12ebb68f3281fc96c69 (patch)
treed8e233727d4e805612618e5037b1b08022faa510
parent4aeadb92130ce650bf5f137071d7777783eaa0e8 (diff)
Don't allocate QMutex members on the heap.
Change-Id: I23f1ccd2f2bbee2fcab2eadfeeec83e1ac489623 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--src/render/materialsystem/shader.cpp6
-rw-r--r--src/render/materialsystem/shader_p.h4
-rw-r--r--src/render/materialsystem/shaderdata.cpp8
-rw-r--r--src/render/materialsystem/shaderdata_p.h2
-rw-r--r--src/render/texture/texture.cpp12
-rw-r--r--src/render/texture/texture_p.h2
6 files changed, 13 insertions, 21 deletions
diff --git a/src/render/materialsystem/shader.cpp b/src/render/materialsystem/shader.cpp
index f2e7bce78..d15147ef9 100644
--- a/src/render/materialsystem/shader.cpp
+++ b/src/render/materialsystem/shader.cpp
@@ -58,7 +58,6 @@ Shader::Shader()
, m_program(Q_NULLPTR)
, m_isLoaded(false)
, m_dna(0)
- , m_mutex(new QMutex())
{
m_shaderCode.resize(static_cast<int>(QShaderProgram::Compute) + 1);
}
@@ -67,7 +66,6 @@ Shader::~Shader()
{
// TO DO: ShaderProgram is leaked as of now
// Fix that taking care that they may be shared given a same dna
- delete m_mutex;
}
void Shader::cleanup()
@@ -232,7 +230,7 @@ void Shader::updateUniforms(GraphicsContext *ctx, const QUniformPack &pack)
void Shader::setFragOutputs(const QHash<QString, int> &fragOutputs)
{
{
- QMutexLocker lock(m_mutex);
+ QMutexLocker lock(&m_mutex);
m_fragOutputs = fragOutputs;
}
updateDNA();
@@ -308,7 +306,7 @@ void Shader::updateDNA()
+ m_shaderCode[QShaderProgram::Fragment]
+ m_shaderCode[QShaderProgram::Compute]);
- QMutexLocker locker(m_mutex);
+ QMutexLocker locker(&m_mutex);
uint attachmentHash = 0;
QHash<QString, int>::const_iterator it = m_fragOutputs.begin();
QHash<QString, int>::const_iterator end = m_fragOutputs.end();
diff --git a/src/render/materialsystem/shader_p.h b/src/render/materialsystem/shader_p.h
index cc38f8c4a..8bf53bbfe 100644
--- a/src/render/materialsystem/shader_p.h
+++ b/src/render/materialsystem/shader_p.h
@@ -48,6 +48,7 @@
// We mean it.
//
+#include <QMutex>
#include <QVector>
#include <Qt3DRender/private/quniformvalue_p.h>
#include <Qt3DRender/private/shadervariables_p.h>
@@ -56,7 +57,6 @@
QT_BEGIN_NAMESPACE
class QOpenGLShaderProgram;
-class QMutex;
namespace Qt3DRender {
@@ -120,7 +120,7 @@ private:
bool m_isLoaded;
ProgramDNA m_dna;
- QMutex *m_mutex;
+ QMutex m_mutex;
void updateDNA();
diff --git a/src/render/materialsystem/shaderdata.cpp b/src/render/materialsystem/shaderdata.cpp
index 9e07c5810..22548498b 100644
--- a/src/render/materialsystem/shaderdata.cpp
+++ b/src/render/materialsystem/shaderdata.cpp
@@ -56,14 +56,12 @@ namespace Render {
QList<Qt3DCore::QNodeId> ShaderData::m_updatedShaderData;
ShaderData::ShaderData()
- : m_mutex(new QMutex)
- , m_managers(Q_NULLPTR)
+ : m_managers(Q_NULLPTR)
{
}
ShaderData::~ShaderData()
{
- delete m_mutex;
}
void ShaderData::setManagers(NodeManagers *managers)
@@ -141,7 +139,7 @@ bool ShaderData::updateViewTransform(const QMatrix4x4 &viewMatrix)
{
// We can't perform this only once as we don't know if we would be call as the root or a
// nested ShaderData
- QMutexLocker lock(m_mutex);
+ QMutexLocker lock(&m_mutex);
// Update transformed properties
// We check the matrices and decide if the transform has changed since the previous call to needsUpdate
@@ -216,7 +214,7 @@ bool ShaderData::updateWorldTransform(const QMatrix4x4 &worldMatrix)
// Called by renderview jobs (several concurrent threads)
void ShaderData::markDirty()
{
- QMutexLocker lock(m_mutex);
+ QMutexLocker lock(&m_mutex);
if (!ShaderData::m_updatedShaderData.contains(peerUuid()))
ShaderData::m_updatedShaderData.append(peerUuid());
}
diff --git a/src/render/materialsystem/shaderdata_p.h b/src/render/materialsystem/shaderdata_p.h
index d87ae8644..6aa75b5b7 100644
--- a/src/render/materialsystem/shaderdata_p.h
+++ b/src/render/materialsystem/shaderdata_p.h
@@ -100,7 +100,7 @@ protected:
PropertyReaderInterfacePtr m_propertyReader;
QHash<QString, QVariant> m_nestedShaderDataProperties;
QHash<QString, QShaderData::TransformType> m_transformedProperties;
- QMutex *m_mutex;
+ QMutex m_mutex;
static QList<Qt3DCore::QNodeId> m_updatedShaderData;
QMatrix4x4 m_worldMatrix;
QMatrix4x4 m_viewMatrix;
diff --git a/src/render/texture/texture.cpp b/src/render/texture/texture.cpp
index a411eedc5..790a8620f 100644
--- a/src/render/texture/texture.cpp
+++ b/src/render/texture/texture.cpp
@@ -76,7 +76,6 @@ Texture::Texture()
, m_filtersAndWrapUpdated(false)
, m_dataUploadRequired(false)
, m_unique(false)
- , m_lock(new QMutex())
, m_textureDNA(0)
, m_textureManager(Q_NULLPTR)
, m_textureImageManager(Q_NULLPTR)
@@ -87,9 +86,6 @@ Texture::Texture()
Texture::~Texture()
{
- if (m_lock != Q_NULLPTR)
- delete m_lock;
- m_lock = Q_NULLPTR;
}
void Texture::cleanup()
@@ -126,7 +122,7 @@ void Texture::updateFromPeer(Qt3DCore::QNode *peer)
{
QAbstractTextureProvider *texture = static_cast<QAbstractTextureProvider *>(peer);
- QMutexLocker lock(m_lock);
+ QMutexLocker lock(&m_lock);
if (texture != Q_NULLPTR) {
m_isDirty = true;
m_width = texture->width();
@@ -165,7 +161,7 @@ QOpenGLTexture *Texture::getOrCreateGLTexture()
// we are receiving a sceneChangeEvent that modifies isDirty or one of the properties
// at the same time
- QMutexLocker lock(m_lock);
+ QMutexLocker lock(&m_lock);
if (m_isDirty) {
delete m_gl;
m_gl = Q_NULLPTR;
@@ -382,7 +378,7 @@ GLint Texture::textureId()
// Any Thread
bool Texture::isTextureReset() const
{
- QMutexLocker lock(m_lock);
+ QMutexLocker lock(&m_lock);
return m_isDirty;
}
@@ -414,7 +410,7 @@ void Texture::setFormat(QAbstractTextureProvider::TextureFormat format)
void Texture::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
{
// The QOpenGLTexture has to be manipulated from the RenderThread only
- QMutexLocker lock(m_lock);
+ QMutexLocker lock(&m_lock);
// We lock here so that we're sure the texture cannot be rebuilt while we are
// modifying one of its properties
QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);
diff --git a/src/render/texture/texture_p.h b/src/render/texture/texture_p.h
index 71fc3f3ec..54738c9cc 100644
--- a/src/render/texture/texture_p.h
+++ b/src/render/texture/texture_p.h
@@ -136,7 +136,7 @@ private:
bool m_formatWasSpecified;
bool m_unique;
- QMutex *m_lock;
+ mutable QMutex m_lock;
TextureDNA m_textureDNA;
TextureManager *m_textureManager;
TextureImageManager *m_textureImageManager;