diff options
author | Mike Krus <mike.krus@kdab.com> | 2017-05-01 14:19:09 +0100 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2017-05-02 08:47:01 +0000 |
commit | 348956c8e270d0c38f495201b99b21634c75b0fa (patch) | |
tree | ec3848bdb1358ad7202f13838e7792cd10e62713 | |
parent | cb7dbc2e40f8258e92a79e8ac46d99a3b65c2a8c (diff) |
Add qAsConst, range-loop might detach Qt container (clazy reports)
Change-Id: I5d541cd0d08f17c25cbb839c111417130d133c3c
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r-- | src/animation/backend/buildblendtreesjob.cpp | 2 | ||||
-rw-r--r-- | src/animation/frontend/qanimationcontroller.cpp | 4 | ||||
-rw-r--r-- | src/animation/frontend/qanimationgroup.cpp | 2 | ||||
-rw-r--r-- | src/animation/frontend/qkeyframeanimation.cpp | 2 | ||||
-rw-r--r-- | src/animation/frontend/qmorphinganimation.cpp | 2 | ||||
-rw-r--r-- | src/animation/frontend/qmorphtarget.cpp | 4 | ||||
-rw-r--r-- | src/plugins/geometryloaders/default/objgeometryloader.cpp | 2 | ||||
-rw-r--r-- | src/plugins/sceneparsers/assimp/assimpimporter.cpp | 6 | ||||
-rw-r--r-- | src/plugins/sceneparsers/gltfexport/gltfexporter.cpp | 8 | ||||
-rw-r--r-- | src/quick3d/quick3dscene2d/items/scene2d.cpp | 4 | ||||
-rw-r--r-- | src/render/frontend/qrenderaspect.cpp | 2 |
11 files changed, 19 insertions, 19 deletions
diff --git a/src/animation/backend/buildblendtreesjob.cpp b/src/animation/backend/buildblendtreesjob.cpp index ac95808bc..fe56099a2 100644 --- a/src/animation/backend/buildblendtreesjob.cpp +++ b/src/animation/backend/buildblendtreesjob.cpp @@ -63,7 +63,7 @@ void BuildBlendTreesJob::setBlendedClipAnimators(const QVector<HBlendedClipAnima // We assume that the structure of blend node tree does not change once a BlendClipAnimator has been set to running void BuildBlendTreesJob::run() { - for (const HBlendedClipAnimator blendedClipAnimatorHandle : m_blendedClipAnimatorHandles) { + for (const HBlendedClipAnimator blendedClipAnimatorHandle : qAsConst(m_blendedClipAnimatorHandles)) { // Retrieve BlendTree node BlendedClipAnimator *blendClipAnimator = m_handler->blendedClipAnimatorManager()->data(blendedClipAnimatorHandle); Q_ASSERT(blendClipAnimator); diff --git a/src/animation/frontend/qanimationcontroller.cpp b/src/animation/frontend/qanimationcontroller.cpp index 5df2c713a..d4c3c4005 100644 --- a/src/animation/frontend/qanimationcontroller.cpp +++ b/src/animation/frontend/qanimationcontroller.cpp @@ -182,7 +182,7 @@ float QAnimationControllerPrivate::scaledPosition(float position) const QAnimationGroup *QAnimationControllerPrivate::findGroup(const QString &name) { - for (QAnimationGroup *g : m_animationGroups) { + for (QAnimationGroup *g : qAsConst(m_animationGroups)) { if (g->name() == name) return g; } @@ -211,7 +211,7 @@ void QAnimationControllerPrivate::extractAnimations() } void QAnimationControllerPrivate::clearAnimations() { - for (Qt3DAnimation::QAnimationGroup *a : m_animationGroups) + for (Qt3DAnimation::QAnimationGroup *a : qAsConst(m_animationGroups)) a->deleteLater(); m_animationGroups.clear(); m_activeAnimationGroup = 0; diff --git a/src/animation/frontend/qanimationgroup.cpp b/src/animation/frontend/qanimationgroup.cpp index 07d0fadc5..365745662 100644 --- a/src/animation/frontend/qanimationgroup.cpp +++ b/src/animation/frontend/qanimationgroup.cpp @@ -109,7 +109,7 @@ QAnimationGroupPrivate::QAnimationGroupPrivate() void QAnimationGroupPrivate::updatePosition(float position) { m_position = position; - for (QAbstractAnimation *aa : m_animations) + for (QAbstractAnimation *aa : qAsConst(m_animations)) aa->setPosition(position); } diff --git a/src/animation/frontend/qkeyframeanimation.cpp b/src/animation/frontend/qkeyframeanimation.cpp index 0b17265a6..1affc737b 100644 --- a/src/animation/frontend/qkeyframeanimation.cpp +++ b/src/animation/frontend/qkeyframeanimation.cpp @@ -190,7 +190,7 @@ void QKeyframeAnimation::setFramePositions(const QVector<float> &positions) d->m_minposition = d->m_framePositions.first(); d->m_maxposition = d->m_framePositions.last(); float lastPos = d->m_minposition; - for (float p : d->m_framePositions) { + for (float p : qAsConst(d->m_framePositions)) { if (p < lastPos || p > d->m_maxposition) qWarning() << "positions not ordered correctly"; lastPos = p; diff --git a/src/animation/frontend/qmorphinganimation.cpp b/src/animation/frontend/qmorphinganimation.cpp index e8f440c45..3824b8d64 100644 --- a/src/animation/frontend/qmorphinganimation.cpp +++ b/src/animation/frontend/qmorphinganimation.cpp @@ -179,7 +179,7 @@ QMorphingAnimationPrivate::QMorphingAnimationPrivate() QMorphingAnimationPrivate::~QMorphingAnimationPrivate() { - for (QVector<float> *weights : m_weights) + for (QVector<float> *weights : qAsConst(m_weights)) delete weights; } diff --git a/src/animation/frontend/qmorphtarget.cpp b/src/animation/frontend/qmorphtarget.cpp index e16dd8698..9dc30b8ba 100644 --- a/src/animation/frontend/qmorphtarget.cpp +++ b/src/animation/frontend/qmorphtarget.cpp @@ -99,7 +99,7 @@ QMorphTargetPrivate::QMorphTargetPrivate() void QMorphTargetPrivate::updateAttributeNames() { m_attributeNames.clear(); - for (const Qt3DRender::QAttribute *attr : m_targetAttributes) + for (const Qt3DRender::QAttribute *attr : qAsConst(m_targetAttributes)) m_attributeNames.push_back(attr->name()); } @@ -148,7 +148,7 @@ void QMorphTarget::setAttributes(const QVector<Qt3DRender::QAttribute *> &attrib void QMorphTarget::addAttribute(Qt3DRender::QAttribute *attribute) { Q_D(QMorphTarget); - for (const Qt3DRender::QAttribute *attr : d->m_targetAttributes) { + for (const Qt3DRender::QAttribute *attr : qAsConst(d->m_targetAttributes)) { if (attr->name() == attribute->name()) return; } diff --git a/src/plugins/geometryloaders/default/objgeometryloader.cpp b/src/plugins/geometryloaders/default/objgeometryloader.cpp index 0f22acc66..a6c635190 100644 --- a/src/plugins/geometryloaders/default/objgeometryloader.cpp +++ b/src/plugins/geometryloaders/default/objgeometryloader.cpp @@ -231,7 +231,7 @@ bool ObjGeometryLoader::doLoad(QIODevice *ioDev, const QString &subMesh) const int indexCount = faceIndexVector.size(); m_indices.clear(); m_indices.reserve(indexCount); - for (const FaceIndices faceIndices : faceIndexVector) { + for (const FaceIndices faceIndices : qAsConst(faceIndexVector)) { const unsigned int i = faceIndexMap.value(faceIndices); m_indices.append(i); } diff --git a/src/plugins/sceneparsers/assimp/assimpimporter.cpp b/src/plugins/sceneparsers/assimp/assimpimporter.cpp index 5d5593585..565c61234 100644 --- a/src/plugins/sceneparsers/assimp/assimpimporter.cpp +++ b/src/plugins/sceneparsers/assimp/assimpimporter.cpp @@ -428,7 +428,7 @@ Qt3DCore::QEntity *AssimpImporter::scene(const QString &id) if (m_scene->m_animations.size() > 0) { qWarning() << "No target found for " << m_scene->m_animations.size() << " animations!"; - for (Qt3DAnimation::QKeyframeAnimation *anim : m_scene->m_animations) + for (Qt3DAnimation::QKeyframeAnimation *anim : qAsConst(m_scene->m_animations)) delete anim; m_scene->m_animations.clear(); } @@ -490,7 +490,7 @@ Qt3DCore::QEntity *AssimpImporter::node(aiNode *node) animations, aiStringToQString(node->mName)); const auto morphTargetList = morphingAnimations.at(0)->morphTargetList(); - for (Qt3DAnimation::QMorphingAnimation *anim : animations) { + for (Qt3DAnimation::QMorphingAnimation *anim : qAsConst(animations)) { anim->setParent(entityNode); anim->setTarget(mesh); anim->setMorphTargets(morphTargetList); @@ -543,7 +543,7 @@ Qt3DCore::QEntity *AssimpImporter::node(aiNode *node) animations, aiStringToQString(node->mName)); - for (Qt3DAnimation::QKeyframeAnimation *anim : animations) { + for (Qt3DAnimation::QKeyframeAnimation *anim : qAsConst(animations)) { anim->setTarget(transform); anim->setParent(entityNode); } diff --git a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp index 373bdf4f4..fce7d5881 100644 --- a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp +++ b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp @@ -1283,7 +1283,7 @@ bool GLTFExporter::saveScene() if (m_rootNodeEmpty) { // Don't export the root node if it is there just to group the scene, so we don't get // an extra empty node when we import the scene back. - for (auto c : m_rootNode->children) + for (auto c : qAsConst(m_rootNode->children)) sceneNodes << exportNodes(c, nodes); } else { sceneNodes << exportNodes(m_rootNode, nodes); @@ -1572,7 +1572,7 @@ bool GLTFExporter::saveScene() QByteArray pre = "<RCC><qresource prefix=\"/gltf_res\">\n"; QByteArray post = "</qresource></RCC>\n"; f.write(pre); - for (const auto &file : m_exportedFiles) { + for (const auto &file : qAsConst(m_exportedFiles)) { QString line = QString(QStringLiteral(" <file>%1</file>\n")).arg(file); f.write(line.toUtf8()); } @@ -1594,7 +1594,7 @@ void GLTFExporter::delNode(GLTFExporter::Node *n) { if (!n) return; - for (auto *c : n->children) + for (auto *c : qAsConst(n->children)) delNode(c); delete n; } @@ -1604,7 +1604,7 @@ QString GLTFExporter::exportNodes(GLTFExporter::Node *n, QJsonObject &nodes) QJsonObject node; node["name"] = n->name; QJsonArray children; - for (auto c : n->children) + for (auto c : qAsConst(n->children)) children << exportNodes(c, nodes); node["children"] = children; if (auto transform = m_transformMap.value(n)) diff --git a/src/quick3d/quick3dscene2d/items/scene2d.cpp b/src/quick3d/quick3dscene2d/items/scene2d.cpp index ded595b36..13165c280 100644 --- a/src/quick3d/quick3dscene2d/items/scene2d.cpp +++ b/src/quick3d/quick3dscene2d/items/scene2d.cpp @@ -501,13 +501,13 @@ void Scene2D::handlePickEvent(int type, const Qt3DRender::QPickEventPtr &ev) void Scene2D::startGrabbing() { - for (Qt3DCore::QNodeId e : m_entities) + for (Qt3DCore::QNodeId e : qAsConst(m_entities)) registerObjectPickerEvents(e); } void Scene2D::stopGrabbing() { - for (Qt3DCore::QNodeId e : m_entities) + for (Qt3DCore::QNodeId e : qAsConst(m_entities)) unregisterObjectPickerEvents(e); } diff --git a/src/render/frontend/qrenderaspect.cpp b/src/render/frontend/qrenderaspect.cpp index ca79f6fde..1f88cb006 100644 --- a/src/render/frontend/qrenderaspect.cpp +++ b/src/render/frontend/qrenderaspect.cpp @@ -595,7 +595,7 @@ void QRenderAspectPrivate::configurePlugin(const QString &plugin) if (!m_pluginConfig.contains(plugin)) { m_pluginConfig.append(plugin); - for (QRenderAspectPrivate *instance : m_instances) + for (QRenderAspectPrivate *instance : qAsConst(m_instances)) instance->loadRenderPlugin(plugin); } } |