diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2019-03-21 16:41:19 +0300 |
---|---|---|
committer | Konstantin Ritt <ritt.ks@gmail.com> | 2019-03-22 18:49:49 +0000 |
commit | b37f8db3e6b0ae172487c7798e1878ae24bfddb5 (patch) | |
tree | c80b9159f545ab5d49e037c3dbbcd444ce7bf144 /tests | |
parent | 9542f9570d16619365e691aaac2053765b9286a2 (diff) |
Optimize BMShape::construct() and avoid UBs
Replace insane static QMap<{const char *, int}, int> with switch-case loop
Change-Id: Iddd1640eee2b0fb78923b3011bd92cc488f7cd6d
Reviewed-by: Rebecca Worledge <rebecca.worledge@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/bodymovin/shape/shapetransform/tst_bmshapetransform.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/auto/bodymovin/shape/shapetransform/tst_bmshapetransform.cpp b/tests/auto/bodymovin/shape/shapetransform/tst_bmshapetransform.cpp index 4a5e78a..bd4ebb5 100644 --- a/tests/auto/bodymovin/shape/shapetransform/tst_bmshapetransform.cpp +++ b/tests/auto/bodymovin/shape/shapetransform/tst_bmshapetransform.cpp @@ -489,11 +489,16 @@ void tst_BMShapeTransform::loadTestData(const QByteArray &filename) BMGroup* group = nullptr; while (shapesIt != shapes.end()) { QJsonObject childObj = (*shapesIt).toObject(); - QByteArray type = childObj.value(QLatin1String("ty")).toVariant().toByteArray(); - if (QLatin1String(type.data()) == QLatin1String(BM_SHAPE_GROUP_STR)) - group = new BMGroup(childObj); + BMShape *shape = BMShape::construct(childObj); + QVERIFY(shape != nullptr); + if (shape->type() == BM_SHAPE_GROUP_IX) { + group = static_cast<BMGroup *>(shape); + break; + } shapesIt++; } + QVERIFY(group != nullptr); + m_transform = static_cast<BMShapeTransform*>(group->findChild("Transform")); QVERIFY(m_transform != nullptr); |