mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 18:41:10 +02:00
Fix crash accessing _modelJointIndicesCache
This commit is contained in:
parent
9261df5c24
commit
73454b06a2
1 changed files with 7 additions and 7 deletions
|
@ -1428,7 +1428,7 @@ int Avatar::getJointIndex(const QString& name) const {
|
||||||
|
|
||||||
withValidJointIndicesCache([&]() {
|
withValidJointIndicesCache([&]() {
|
||||||
if (_modelJointIndicesCache.contains(name)) {
|
if (_modelJointIndicesCache.contains(name)) {
|
||||||
result = _modelJointIndicesCache[name] - 1;
|
result = _modelJointIndicesCache.value(name) - 1;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
|
@ -1439,22 +1439,22 @@ QStringList Avatar::getJointNames() const {
|
||||||
withValidJointIndicesCache([&]() {
|
withValidJointIndicesCache([&]() {
|
||||||
// find out how large the vector needs to be
|
// find out how large the vector needs to be
|
||||||
int maxJointIndex = -1;
|
int maxJointIndex = -1;
|
||||||
QHashIterator<QString, int> k(_modelJointIndicesCache);
|
QHash<QString, int>::const_iterator k = _modelJointIndicesCache.constBegin();
|
||||||
while (k.hasNext()) {
|
while (k != _modelJointIndicesCache.constEnd()) {
|
||||||
k.next();
|
|
||||||
int index = k.value();
|
int index = k.value();
|
||||||
if (index > maxJointIndex) {
|
if (index > maxJointIndex) {
|
||||||
maxJointIndex = index;
|
maxJointIndex = index;
|
||||||
}
|
}
|
||||||
|
++k;
|
||||||
}
|
}
|
||||||
// iterate through the hash and put joint names
|
// iterate through the hash and put joint names
|
||||||
// into the vector at their indices
|
// into the vector at their indices
|
||||||
QVector<QString> resultVector(maxJointIndex+1);
|
QVector<QString> resultVector(maxJointIndex+1);
|
||||||
QHashIterator<QString, int> i(_modelJointIndicesCache);
|
QHash<QString, int>::const_iterator i = _modelJointIndicesCache.constBegin();
|
||||||
while (i.hasNext()) {
|
while (i != _modelJointIndicesCache.constEnd()) {
|
||||||
i.next();
|
|
||||||
int index = i.value();
|
int index = i.value();
|
||||||
resultVector[index] = i.key();
|
resultVector[index] = i.key();
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
// convert to QList and drop out blanks
|
// convert to QList and drop out blanks
|
||||||
result = resultVector.toList();
|
result = resultVector.toList();
|
||||||
|
|
Loading…
Reference in a new issue