aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-03-07 14:42:59 -0800
committerThiago Macieira <thiago.macieira@intel.com>2015-05-13 20:30:26 +0000
commit30aa0a1cc9812bd2a9ead91e3f412808ebe7daff (patch)
tree3165986d36f4727bb8ec111b7db22eb45a067867 /src/quick
parent66be8fcc05f0e51f12c215af3d5ab74d729386ba (diff)
QtQuick: Fix const correctness in old style casts
Found with GCC's -Wcast-qual. Change-Id: Ia0aac2f09e9245339951ffff13c9589afabc7ade Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/items/qquickshadereffectnode.cpp2
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp8
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h7
-rw-r--r--src/quick/scenegraph/coreapi/qsgnode.cpp14
-rw-r--r--src/quick/scenegraph/qsgcontext.cpp10
-rw-r--r--src/quick/scenegraph/qsgrenderloop.cpp2
-rw-r--r--src/quick/util/qquickanimation.cpp4
-rw-r--r--src/quick/util/qquicksmoothedanimation.cpp2
-rw-r--r--src/quick/util/qquickspringanimation.cpp2
-rw-r--r--src/quick/util/qquicktimeline.cpp2
10 files changed, 29 insertions, 24 deletions
diff --git a/src/quick/items/qquickshadereffectnode.cpp b/src/quick/items/qquickshadereffectnode.cpp
index 6415c0ad22..de6cae0ea6 100644
--- a/src/quick/items/qquickshadereffectnode.cpp
+++ b/src/quick/items/qquickshadereffectnode.cpp
@@ -341,7 +341,7 @@ bool QQuickShaderEffectMaterialKey::operator != (const QQuickShaderEffectMateria
uint qHash(const QQuickShaderEffectMaterialKey &key)
{
- uint hash = qHash((void *)key.className);
+ uint hash = qHash((const void *)key.className);
typedef QQuickShaderEffectMaterialKey Key;
for (int shaderType = 0; shaderType < Key::ShaderTypeCount; ++shaderType)
hash = hash * 31337 + qHash(key.sourceCode[shaderType]);
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index 886e614620..63938d50a9 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -1693,8 +1693,8 @@ void Renderer::uploadMergedElement(Element *e, int vaOffset, char **vertexData,
if (((const QMatrix4x4_Accessor &) localx).flagBits == 1) {
for (int i=0; i<vCount; ++i) {
Pt *p = (Pt *) vdata;
- p->x += ((QMatrix4x4_Accessor &) localx).m[3][0];
- p->y += ((QMatrix4x4_Accessor &) localx).m[3][1];
+ p->x += ((const QMatrix4x4_Accessor &) localx).m[3][0];
+ p->y += ((const QMatrix4x4_Accessor &) localx).m[3][1];
vdata += vSize;
}
} else if (((const QMatrix4x4_Accessor &) localx).flagBits > 1) {
@@ -1935,11 +1935,11 @@ void Renderer::uploadBatch(Batch *b)
if (attr.isVertexCoordinate)
dump << "* ";
for (int t=0; t<attr.tupleSize; ++t)
- dump << *(float *)(vd + offset + t * sizeof(float)) << " ";
+ dump << *(const float *)(vd + offset + t * sizeof(float)) << " ";
} else if (attr.type == GL_UNSIGNED_BYTE) {
dump << "ubyte ";
for (int t=0; t<attr.tupleSize; ++t)
- dump << *(unsigned char *)(vd + offset + t * sizeof(unsigned char)) << " ";
+ dump << *(const unsigned char *)(vd + offset + t * sizeof(unsigned char)) << " ";
}
dump << ") ";
offset += attr.tupleSize * size_of_type(attr.type);
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
index 8996d5a092..f87dd75c8c 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
@@ -85,7 +85,12 @@ public:
for (int i=0; i<PageSize; ++i) blocks[i] = i;
}
- Type *at(uint index) const
+ const Type *at(uint index) const
+ {
+ return (Type *) &data[index * sizeof(Type)];
+ }
+
+ Type *at(uint index)
{
return (Type *) &data[index * sizeof(Type)];
}
diff --git a/src/quick/scenegraph/coreapi/qsgnode.cpp b/src/quick/scenegraph/coreapi/qsgnode.cpp
index e52713e804..71f4f62db9 100644
--- a/src/quick/scenegraph/coreapi/qsgnode.cpp
+++ b/src/quick/scenegraph/coreapi/qsgnode.cpp
@@ -1457,7 +1457,7 @@ QDebug operator<<(QDebug d, const QSGGeometryNode *n)
d << "Geometry(null)";
return d;
}
- d << "GeometryNode(" << hex << (void *) n << dec;
+ d << "GeometryNode(" << hex << (const void *) n << dec;
const QSGGeometry *g = n->geometry();
@@ -1508,7 +1508,7 @@ QDebug operator<<(QDebug d, const QSGClipNode *n)
d << "ClipNode(null)";
return d;
}
- d << "ClipNode(" << hex << (void *) n << dec;
+ d << "ClipNode(" << hex << (const void *) n << dec;
if (n->childCount())
d << "children=" << n->childCount();
@@ -1531,7 +1531,7 @@ QDebug operator<<(QDebug d, const QSGTransformNode *n)
}
const QMatrix4x4 m = n->matrix();
d << "TransformNode(";
- d << hex << (void *) n << dec;
+ d << hex << (const void *) n << dec;
if (m.isIdentity())
d << "identity";
else if (m.determinant() == 1 && m(0, 0) == 1 && m(1, 1) == 1 && m(2, 2) == 1)
@@ -1553,7 +1553,7 @@ QDebug operator<<(QDebug d, const QSGOpacityNode *n)
return d;
}
d << "OpacityNode(";
- d << hex << (void *) n << dec;
+ d << hex << (const void *) n << dec;
d << "opacity=" << n->opacity()
<< "combined=" << n->combinedOpacity()
<< (n->isSubtreeBlocked() ? "*BLOCKED*" : "");
@@ -1571,7 +1571,7 @@ QDebug operator<<(QDebug d, const QSGRootNode *n)
d << "RootNode(null)";
return d;
}
- d << "RootNode" << hex << (void *) n << (n->isSubtreeBlocked() ? "*BLOCKED*" : "");
+ d << "RootNode" << hex << (const void *) n << (n->isSubtreeBlocked() ? "*BLOCKED*" : "");
#ifdef QSG_RUNTIME_DESCRIPTION
d << QSGNodePrivate::description(n);
#endif
@@ -1604,7 +1604,7 @@ QDebug operator<<(QDebug d, const QSGNode *n)
d << static_cast<const QSGOpacityNode *>(n);
break;
case QSGNode::RenderNodeType:
- d << "RenderNode(" << hex << (void *) n << dec
+ d << "RenderNode(" << hex << (const void *) n << dec
<< "flags=" << (int) n->flags() << dec
<< (n->isSubtreeBlocked() ? "*BLOCKED*" : "");
#ifdef QSG_RUNTIME_DESCRIPTION
@@ -1613,7 +1613,7 @@ QDebug operator<<(QDebug d, const QSGNode *n)
d << ')';
break;
default:
- d << "Node(" << hex << (void *) n << dec
+ d << "Node(" << hex << (const void *) n << dec
<< "flags=" << (int) n->flags() << dec
<< (n->isSubtreeBlocked() ? "*BLOCKED*" : "");
#ifdef QSG_RUNTIME_DESCRIPTION
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index dd071d757e..418d571ae6 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -315,11 +315,11 @@ QSGContext::QSGContext(QObject *parent) :
// Adds compatibility with Qt 5.3 and earlier's QSG_RENDER_TIMING
if (qEnvironmentVariableIsSet("QSG_RENDER_TIMING")) {
- ((QLoggingCategory &) QSG_LOG_TIME_GLYPH()).setEnabled(QtDebugMsg, true);
- ((QLoggingCategory &) QSG_LOG_TIME_TEXTURE()).setEnabled(QtDebugMsg, true);
- ((QLoggingCategory &) QSG_LOG_TIME_RENDERER()).setEnabled(QtDebugMsg, true);
- ((QLoggingCategory &) QSG_LOG_TIME_RENDERLOOP()).setEnabled(QtDebugMsg, true);
- ((QLoggingCategory &) QSG_LOG_TIME_COMPILATION()).setEnabled(QtDebugMsg, true);
+ const_cast<QLoggingCategory &>(QSG_LOG_TIME_GLYPH()).setEnabled(QtDebugMsg, true);
+ const_cast<QLoggingCategory &>(QSG_LOG_TIME_TEXTURE()).setEnabled(QtDebugMsg, true);
+ const_cast<QLoggingCategory &>(QSG_LOG_TIME_RENDERER()).setEnabled(QtDebugMsg, true);
+ const_cast<QLoggingCategory &>(QSG_LOG_TIME_RENDERLOOP()).setEnabled(QtDebugMsg, true);
+ const_cast<QLoggingCategory &>(QSG_LOG_TIME_COMPILATION()).setEnabled(QtDebugMsg, true);
}
}
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp
index b7a6475c23..781e82fbc4 100644
--- a/src/quick/scenegraph/qsgrenderloop.cpp
+++ b/src/quick/scenegraph/qsgrenderloop.cpp
@@ -152,7 +152,7 @@ QSGRenderLoop *QSGRenderLoop::instance()
// For compatibility with 5.3 and earlier's QSG_INFO environment variables
if (qEnvironmentVariableIsSet("QSG_INFO"))
- ((QLoggingCategory &) QSG_LOG_INFO()).setEnabled(QtDebugMsg, true);
+ const_cast<QLoggingCategory &>(QSG_LOG_INFO()).setEnabled(QtDebugMsg, true);
s_instance = QSGContext::createWindowManager();
diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp
index a39d734de3..3a0c19e3d2 100644
--- a/src/quick/util/qquickanimation.cpp
+++ b/src/quick/util/qquickanimation.cpp
@@ -867,7 +867,7 @@ void QActionAnimation::updateState(State newState, State oldState)
void QActionAnimation::debugAnimation(QDebug d) const
{
- d << "ActionAnimation(" << hex << (void *) this << dec << ")";
+ d << "ActionAnimation(" << hex << (const void *) this << dec << ")";
if (animAction) {
int indentLevel = 1;
@@ -1960,7 +1960,7 @@ void QQuickBulkValueAnimator::topLevelAnimationLoopChanged()
void QQuickBulkValueAnimator::debugAnimation(QDebug d) const
{
- d << "BulkValueAnimation(" << hex << (void *) this << dec << ")" << "duration:" << duration();
+ d << "BulkValueAnimation(" << hex << (const void *) this << dec << ")" << "duration:" << duration();
if (animValue) {
int indentLevel = 1;
diff --git a/src/quick/util/qquicksmoothedanimation.cpp b/src/quick/util/qquicksmoothedanimation.cpp
index 71dacfcb1d..6d585d38a7 100644
--- a/src/quick/util/qquicksmoothedanimation.cpp
+++ b/src/quick/util/qquicksmoothedanimation.cpp
@@ -307,7 +307,7 @@ void QSmoothedAnimation::init()
void QSmoothedAnimation::debugAnimation(QDebug d) const
{
- d << "SmoothedAnimationJob(" << hex << (void *) this << dec << ")" << "duration:" << userDuration
+ d << "SmoothedAnimationJob(" << hex << (const void *) this << dec << ")" << "duration:" << userDuration
<< "velocity:" << velocity << "target:" << target.object() << "property:" << target.name()
<< "to:" << to << "current velocity:" << trackVelocity;
}
diff --git a/src/quick/util/qquickspringanimation.cpp b/src/quick/util/qquickspringanimation.cpp
index b68afbecdd..125d6f5ef6 100644
--- a/src/quick/util/qquickspringanimation.cpp
+++ b/src/quick/util/qquickspringanimation.cpp
@@ -313,7 +313,7 @@ void QSpringAnimation::updateState(QAbstractAnimationJob::State newState, QAbstr
void QSpringAnimation::debugAnimation(QDebug d) const
{
- d << "SpringAnimationJob(" << hex << (void *) this << dec << ")" << "velocity:" << maxVelocity
+ d << "SpringAnimationJob(" << hex << (const void *) this << dec << ")" << "velocity:" << maxVelocity
<< "spring:" << spring << "damping:" << damping << "epsilon:" << epsilon << "modulus:" << modulus
<< "mass:" << mass << "target:" << target.object() << "property:" << target.name()
<< "to:" << to << "current velocity:" << velocity;
diff --git a/src/quick/util/qquicktimeline.cpp b/src/quick/util/qquicktimeline.cpp
index 8cd9b349d8..74754a0bfb 100644
--- a/src/quick/util/qquicktimeline.cpp
+++ b/src/quick/util/qquicktimeline.cpp
@@ -717,7 +717,7 @@ void QQuickTimeLine::updateCurrentTime(int v)
void QQuickTimeLine::debugAnimation(QDebug d) const
{
- d << "QuickTimeLine(" << hex << (void *) this << dec << ")";
+ d << "QuickTimeLine(" << hex << (const void *) this << dec << ")";
}
bool operator<(const QPair<int, Update> &lhs,