fix crash when saving mesh with texture without changing txtname

This commit is contained in:
alemuntoni 2021-06-09 08:50:07 +02:00
parent 2b475c7344
commit 0cd47744cb

View File

@ -175,13 +175,15 @@ void MeshModel::changeTextureName(
const std::string& oldName,
std::string newName)
{
auto mit = textures.find(oldName);
auto tit = std::find(cm.textures.begin(), cm.textures.end(), oldName);
if (mit != textures.end() && tit != cm.textures.end()){
*tit = newName;
if (oldName != newName) {
auto mit = textures.find(oldName);
auto tit = std::find(cm.textures.begin(), cm.textures.end(), oldName);
if (mit != textures.end() && tit != cm.textures.end()){
*tit = newName;
textures[newName] = mit->second;
textures.erase(mit);
textures[newName] = mit->second;
textures.erase(mit);
}
}
}