mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 03:23:33 +02:00
respond to code review
This commit is contained in:
parent
7b656d5ead
commit
b1c5a04531
4 changed files with 10 additions and 10 deletions
|
@ -986,8 +986,8 @@ bool EntityItem::isMoving() const {
|
|||
}
|
||||
|
||||
EntityTreePointer EntityItem::getTree() const {
|
||||
EntityTreeElementPointer elt = getElement();
|
||||
EntityTreePointer tree = elt ? elt->getTree() : nullptr;
|
||||
EntityTreeElementPointer containingElement = getElement();
|
||||
EntityTreePointer tree = containingElement ? containingElement->getTree() : nullptr;
|
||||
return tree;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,14 +47,14 @@ bool EntityScriptingInterface::canRez() {
|
|||
return nodeList->getThisNodeCanRez();
|
||||
}
|
||||
|
||||
void EntityScriptingInterface::setEntityTree(EntityTreePointer modelTree) {
|
||||
void EntityScriptingInterface::setEntityTree(EntityTreePointer elementTree) {
|
||||
if (_entityTree) {
|
||||
disconnect(_entityTree.get(), &EntityTree::addingEntity, this, &EntityScriptingInterface::addingEntity);
|
||||
disconnect(_entityTree.get(), &EntityTree::deletingEntity, this, &EntityScriptingInterface::deletingEntity);
|
||||
disconnect(_entityTree.get(), &EntityTree::clearingEntities, this, &EntityScriptingInterface::clearingEntities);
|
||||
}
|
||||
|
||||
_entityTree = modelTree;
|
||||
_entityTree = elementTree;
|
||||
|
||||
if (_entityTree) {
|
||||
connect(_entityTree.get(), &EntityTree::addingEntity, this, &EntityScriptingInterface::addingEntity);
|
||||
|
|
|
@ -45,9 +45,9 @@ void EntityTree::createRootElement() {
|
|||
OctreeElementPointer EntityTree::createNewElement(unsigned char* octalCode) {
|
||||
EntityTreeElementPointer newElement = EntityTreeElementPointer(new EntityTreeElement(octalCode),
|
||||
// see comment int EntityTreeElement::createNewElement
|
||||
[=](EntityTreeElement* elt) {
|
||||
EntityTreeElementPointer tmpSharedPointer(elt);
|
||||
elt->notifyDeleteHooks();
|
||||
[=](EntityTreeElement* dyingElement) {
|
||||
EntityTreeElementPointer tmpSharedPointer(dyingElement);
|
||||
dyingElement->notifyDeleteHooks();
|
||||
});
|
||||
newElement->setTree(std::static_pointer_cast<EntityTree>(shared_from_this()));
|
||||
return std::static_pointer_cast<OctreeElement>(newElement);
|
||||
|
|
|
@ -42,12 +42,12 @@ OctreeElementPointer EntityTreeElement::createNewElement(unsigned char* octalCod
|
|||
// or the destructor wouldn't have been called). The destructor also can't
|
||||
// make a new shared pointer -- shared_from_this() is forbidden in a destructor, and
|
||||
// using OctreeElementPointer(this) also fails. So, I've installed a custom deleter:
|
||||
[=](EntityTreeElement* elt) {
|
||||
[=](EntityTreeElement* dyingElement) {
|
||||
// make a new shared pointer with a reference count of 1 (and no custom deleter)
|
||||
EntityTreeElementPointer tmpSharedPointer(elt);
|
||||
EntityTreeElementPointer tmpSharedPointer(dyingElement);
|
||||
// call notifyDeleteHooks which will use shared_from_this() to get this same
|
||||
// shared pointer, for use with the elementDeleted calls.
|
||||
elt->notifyDeleteHooks();
|
||||
dyingElement->notifyDeleteHooks();
|
||||
// And now tmpSharedPointer's reference count drops to zero and the
|
||||
// normal destructors are called.
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue