Merge pull request #11513 from hyperlogic/bug-fix/set-compund-shape-url-deadlock

Bug fix for deadlock in ModelEntityItem::setCompundShapeURL()
This commit is contained in:
Anthony Thibault 2017-10-03 13:31:01 -07:00 committed by GitHub
commit 2dc080479c
2 changed files with 9 additions and 11 deletions

View file

@ -217,7 +217,7 @@ void ModelEntityItem::debugDump() const {
void ModelEntityItem::setShapeType(ShapeType type) { void ModelEntityItem::setShapeType(ShapeType type) {
withWriteLock([&] { withWriteLock([&] {
if (type != _shapeType) { if (type != _shapeType) {
if (type == SHAPE_TYPE_STATIC_MESH && _dynamic) { if (type == SHAPE_TYPE_STATIC_MESH && _dynamic) {
// dynamic and STATIC_MESH are incompatible // dynamic and STATIC_MESH are incompatible
// since the shape is being set here we clear the dynamic bit // since the shape is being set here we clear the dynamic bit
_dynamic = false; _dynamic = false;
@ -260,9 +260,9 @@ void ModelEntityItem::setModelURL(const QString& url) {
void ModelEntityItem::setCompoundShapeURL(const QString& url) { void ModelEntityItem::setCompoundShapeURL(const QString& url) {
withWriteLock([&] { withWriteLock([&] {
if (_compoundShapeURL != url) { if (_compoundShapeURL.get() != url) {
ShapeType oldType = computeTrueShapeType(); ShapeType oldType = computeTrueShapeType();
_compoundShapeURL = url; _compoundShapeURL.set(url);
if (oldType != computeTrueShapeType()) { if (oldType != computeTrueShapeType()) {
_dirtyFlags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; _dirtyFlags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS;
} }
@ -496,10 +496,8 @@ bool ModelEntityItem::hasModel() const {
return !_modelURL.isEmpty(); return !_modelURL.isEmpty();
}); });
} }
bool ModelEntityItem::hasCompoundShapeURL() const { bool ModelEntityItem::hasCompoundShapeURL() const {
return resultWithReadLock<bool>([&] { return _compoundShapeURL.get().isEmpty();
return !_compoundShapeURL.isEmpty();
});
} }
QString ModelEntityItem::getModelURL() const { QString ModelEntityItem::getModelURL() const {
@ -509,9 +507,7 @@ QString ModelEntityItem::getModelURL() const {
} }
QString ModelEntityItem::getCompoundShapeURL() const { QString ModelEntityItem::getCompoundShapeURL() const {
return resultWithReadLock<QString>([&] { return _compoundShapeURL.get();
return _compoundShapeURL;
});
} }
void ModelEntityItem::setColor(const rgbColor& value) { void ModelEntityItem::setColor(const rgbColor& value) {

View file

@ -14,6 +14,7 @@
#include "EntityItem.h" #include "EntityItem.h"
#include <JointData.h> #include <JointData.h>
#include <ThreadSafeValueCache.h>
#include "AnimationPropertyGroup.h" #include "AnimationPropertyGroup.h"
class ModelEntityItem : public EntityItem { class ModelEntityItem : public EntityItem {
@ -153,7 +154,8 @@ protected:
rgbColor _color; rgbColor _color;
QString _modelURL; QString _modelURL;
QString _compoundShapeURL;
ThreadSafeValueCache<QString> _compoundShapeURL;
AnimationPropertyGroup _animationProperties; AnimationPropertyGroup _animationProperties;