From 8cecc55d64b555058592f5ecbb0403a93dab4e25 Mon Sep 17 00:00:00 2001 From: elsid Date: Wed, 27 Jul 2022 19:51:30 +0200 Subject: [PATCH] Fix inserting texture to map Avoid using invalidated iterator after erase call. Use insert_or_assing instead of operator[] because OSGTexture doesn't have a default constructor. --- components/myguiplatform/myguirendermanager.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/components/myguiplatform/myguirendermanager.cpp b/components/myguiplatform/myguirendermanager.cpp index e0e8e245a3..2ac65c559d 100644 --- a/components/myguiplatform/myguirendermanager.cpp +++ b/components/myguiplatform/myguirendermanager.cpp @@ -530,13 +530,8 @@ bool RenderManager::isFormatSupported(MyGUI::PixelFormat /*format*/, MyGUI::Text MyGUI::ITexture* RenderManager::createTexture(const std::string &name) { - auto item = mTextures.find(name); - if (item != mTextures.end()) - mTextures.erase(item); - - item = mTextures.emplace_hint(item, name, OSGTexture(name, mImageManager)); - - return &item->second; + const auto it = mTextures.insert_or_assign(name, OSGTexture(name, mImageManager)).first; + return &it->second; } void RenderManager::destroyTexture(MyGUI::ITexture *texture)