mirror of
https://github.com/rt64/rt64.git
synced 2024-12-26 21:18:31 +00:00
Fix edge case with reference counting.
This commit is contained in:
parent
ab7d96f609
commit
efbda3f0ee
@ -210,6 +210,7 @@ namespace RT64 {
|
|||||||
for (size_t i = 0; i < textureReplacements.size(); i++) {
|
for (size_t i = 0; i < textureReplacements.size(); i++) {
|
||||||
if (textureReplacements[i] != nullptr) {
|
if (textureReplacements[i] != nullptr) {
|
||||||
textureReplacements[i] = nullptr;
|
textureReplacements[i] = nullptr;
|
||||||
|
textureReplacementReferenceCounted[i] = false;
|
||||||
versions[i]++;
|
versions[i]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -258,6 +259,17 @@ namespace RT64 {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do nothing if it's the same texture. If the operations were done correctly, it's not possible for either the texture or the
|
||||||
|
// replacement to be any different, so the operation can be considered a no-op.
|
||||||
|
if (texture == textureReplacements[it->second]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If it's a different texture and a texture was already replaced, decrement its reference.
|
||||||
|
if ((textureReplacements[it->second] != nullptr) && textureReplacementReferenceCounted[it->second]) {
|
||||||
|
replacementMap.decrementReference(textureReplacements[it->second]);
|
||||||
|
}
|
||||||
|
|
||||||
Texture *replacedTexture = textures[it->second];
|
Texture *replacedTexture = textures[it->second];
|
||||||
textureReplacements[it->second] = texture;
|
textureReplacements[it->second] = texture;
|
||||||
textureReplacementReferenceCounted[it->second] = referenceCounted;
|
textureReplacementReferenceCounted[it->second] = referenceCounted;
|
||||||
|
Loading…
Reference in New Issue
Block a user