mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 11:35:20 +02:00
Merge pull request #15489 from luiscuenca/jointIndicesCrashFix
Fix memory corruption in _modelJointIndicesCache QHash
This commit is contained in:
commit
b0af8b1bdc
1 changed files with 3 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,9 +1439,7 @@ 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);
|
for (auto k = _modelJointIndicesCache.constBegin(); k != _modelJointIndicesCache.constEnd(); k++) {
|
||||||
while (k.hasNext()) {
|
|
||||||
k.next();
|
|
||||||
int index = k.value();
|
int index = k.value();
|
||||||
if (index > maxJointIndex) {
|
if (index > maxJointIndex) {
|
||||||
maxJointIndex = index;
|
maxJointIndex = index;
|
||||||
|
@ -1450,9 +1448,7 @@ QStringList Avatar::getJointNames() const {
|
||||||
// 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);
|
for (auto i = _modelJointIndicesCache.constBegin(); i != _modelJointIndicesCache.constEnd(); i++) {
|
||||||
while (i.hasNext()) {
|
|
||||||
i.next();
|
|
||||||
int index = i.value();
|
int index = i.value();
|
||||||
resultVector[index] = i.key();
|
resultVector[index] = i.key();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue