Fixed child nodes not deleted if the importer failed to add them to the scene root node.
parent
8177706716
commit
9deb8fb786
|
@ -124,6 +124,17 @@ void HL1MDLLoader::release_resources() {
|
|||
delete[] anim_headers_;
|
||||
anim_headers_ = nullptr;
|
||||
}
|
||||
|
||||
if (rootnode_children_.size()) {
|
||||
// Here, it means that the nodes were not added to the
|
||||
// scene root node. We still have to delete them.
|
||||
for (auto it = rootnode_children_.begin(); it != rootnode_children_.end(); ++it) {
|
||||
if (*it)
|
||||
delete *it;
|
||||
}
|
||||
// Ensure this happens only once.
|
||||
rootnode_children_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -171,6 +182,10 @@ void HL1MDLLoader::load_file() {
|
|||
scene_->mRootNode->addChildren(
|
||||
static_cast<unsigned int>(rootnode_children_.size()),
|
||||
rootnode_children_.data());
|
||||
|
||||
// Clear the list of nodes so they will not be destroyed
|
||||
// when resources are released.
|
||||
rootnode_children_.clear();
|
||||
}
|
||||
|
||||
release_resources();
|
||||
|
|
Loading…
Reference in New Issue