avoid shared_from_this while constructing

This commit is contained in:
Seth Alves 2015-10-23 12:55:48 -07:00
parent bf290c35be
commit 22af5b27ab
4 changed files with 9 additions and 0 deletions

View file

@ -60,6 +60,7 @@ AvatarData::AvatarData() :
setBodyPitch(0.0f);
setBodyYaw(-90.0f);
setBodyRoll(0.0f);
_constructing = false;
}
AvatarData::~AvatarData() {

View file

@ -85,6 +85,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID) :
quint64 now = usecTimestampNow();
_lastSimulated = now;
_lastUpdated = now;
_constructing = false;
}
EntityItem::~EntityItem() {

View file

@ -32,6 +32,11 @@ SpatiallyNestablePointer SpatiallyNestable::getParentPointer() const {
return nullptr;
}
if (_constructing) {
// we can't use shared_from_this yet, so stop here.
return nullptr;
}
SpatiallyNestableConstPointer constThisPointer = shared_from_this();
SpatiallyNestablePointer thisPointer = std::const_pointer_cast<SpatiallyNestable>(constThisPointer); // ermahgerd !!!

View file

@ -82,6 +82,8 @@ public:
NestableTypes::NestableType getNestableType() const { return _nestableType; }
protected:
bool _constructing = true;
NestableTypes::NestableType _nestableType; // EntityItem or an AvatarData
QUuid _id;
QUuid _parentID; // what is this thing's transform relative to?