|
@@ -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();
|