mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-27 05:32:45 +00:00
Merge pull request #1142 from klusark/mat
GRIM: Fix deleting material when it is still needed
This commit is contained in:
commit
3c2203e8c6
@ -50,6 +50,7 @@ void MaterialComponent::init() {
|
||||
for (int i = 0; i < model->_numMaterials; ++i) {
|
||||
if (_name.compareToIgnoreCase(model->_materials[i]->getFilename()) == 0) {
|
||||
_mat = model->_materials[i];
|
||||
_mat->reference();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ Model::Model(const Common::String &filename, Common::SeekableReadStream *data, C
|
||||
Model::~Model() {
|
||||
for (int i = 0; i < _numMaterials; ++i) {
|
||||
if (!_materialsShared[i]) {
|
||||
delete _materials[i];
|
||||
_materials[i]->dereference();
|
||||
}
|
||||
}
|
||||
delete[] _materials;
|
||||
@ -247,6 +247,7 @@ void Model::loadMaterial(int index, CMap *cmap) {
|
||||
_materials[index] = mat;
|
||||
} else {
|
||||
_materials[index] = g_resourceloader->loadMaterial(_materialNames[index], cmap, false);
|
||||
_materials[index]->reference();
|
||||
}
|
||||
_materialsShared[index] = false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user