protect Base3DOverlay::_name with a mutex

This commit is contained in:
Seth Alves 2018-09-06 09:03:28 -07:00
parent 03f51352aa
commit 69ae04ab09
2 changed files with 21 additions and 4 deletions

View file

@ -238,8 +238,10 @@ void Base3DOverlay::setProperties(const QVariantMap& originalProperties) {
*/ */
QVariant Base3DOverlay::getProperty(const QString& property) { QVariant Base3DOverlay::getProperty(const QString& property) {
if (property == "name") { if (property == "name") {
return _nameLock.resultWithReadLock<QString>([&] {
return _name; return _name;
} }
}
if (property == "position" || property == "start" || property == "p1" || property == "point") { if (property == "position" || property == "start" || property == "p1" || property == "point") {
return vec3toVariant(getWorldPosition()); return vec3toVariant(getWorldPosition());
} }
@ -346,6 +348,20 @@ void Base3DOverlay::setVisible(bool visible) {
notifyRenderVariableChange(); notifyRenderVariableChange();
} }
QString Base3DOverlay::getName() const {
return _nameLock.resultWithReadLock<QString>([&] {
return QString("Overlay:") + _name;
}
}
void Base3DOverlay::setName(QString name) {
_nameLock.withWriteLock([&] {
_name = name;
});
}
render::ItemKey Base3DOverlay::getKey() { render::ItemKey Base3DOverlay::getKey() {
auto builder = render::ItemKey::Builder(Overlay::getKey()); auto builder = render::ItemKey::Builder(Overlay::getKey());

View file

@ -29,8 +29,8 @@ public:
virtual OverlayID getOverlayID() const override { return OverlayID(getID().toString()); } virtual OverlayID getOverlayID() const override { return OverlayID(getID().toString()); }
void setOverlayID(OverlayID overlayID) override { setID(overlayID); } void setOverlayID(OverlayID overlayID) override { setID(overlayID); }
virtual QString getName() const override { return QString("Overlay:") + _name; } virtual QString getName() const override;
void setName(QString name) { _name = name; } void setName(QString name);
// getters // getters
virtual bool is3D() const override { return true; } virtual bool is3D() const override { return true; }
@ -107,6 +107,7 @@ protected:
mutable bool _renderVariableDirty { true }; mutable bool _renderVariableDirty { true };
QString _name; QString _name;
mutable ReadWriteLockable _nameLock;
}; };
#endif // hifi_Base3DOverlay_h #endif // hifi_Base3DOverlay_h