Cleanups ddbf1ea770 which fixes 4ffc005a7f. Sprites can not be inserted twice.

This was SVN commit r25702.
This commit is contained in:
vladislavbelov
2021-06-06 09:31:36 +00:00
parent 374b869480
commit 337c4100ce
+4 -3
View File
@@ -74,7 +74,6 @@ void GUIRenderer::UpdateDrawCallCache(const CGUI& pGUI, DrawCalls& Calls, const
if (Size.left == Size.right && Size.top == Size.bottom)
return;
std::map<CStr, std::unique_ptr<const CGUISprite>>::iterator it(Sprites.find(SpriteName));
if (it == Sprites.end())
{
@@ -96,6 +95,7 @@ void GUIRenderer::UpdateDrawCallCache(const CGUI& pGUI, DrawCalls& Calls, const
LOGERROR("Trying to use a sprite that doesn't exist (\"%s\").", SpriteName.c_str());
return;
}
auto sprite = std::make_unique<CGUISprite>();
VfsPath TextureName = VfsPath("art/textures/ui") / wstring_from_utf8(SpriteName.AfterLast(":"));
if (SpriteName.Find("stretched:") != -1)
@@ -164,13 +164,14 @@ void GUIRenderer::UpdateDrawCallCache(const CGUI& pGUI, DrawCalls& Calls, const
sprite->AddImage(std::move(image));
}
if (sprite->m_Images.empty())
{
LOGERROR("Trying to use a sprite that doesn't exist (\"%s\").", SpriteName.c_str());
return;
}
else
it = Sprites.insert_or_assign(SpriteName, std::move(sprite)).first;
it = Sprites.emplace(SpriteName, std::move(sprite)).first;
}
Calls.reserve(it->second->m_Images.size());