[Localization] Fix demos by locking the mutex only when necessary

This commit is contained in:
momo5502 2017-06-05 18:44:33 +02:00
parent 92b0dcffff
commit 001939166b

View File

@ -49,15 +49,17 @@ namespace Components
if (!Localization::UseLocalization.get<bool>()) return key; if (!Localization::UseLocalization.get<bool>()) return key;
Game::LocalizeEntry* entry = nullptr; Game::LocalizeEntry* entry = nullptr;
std::lock_guard<std::recursive_mutex> _(Localization::LocalizeMutex); {
std::lock_guard<std::recursive_mutex> _(Localization::LocalizeMutex);
if (Localization::TempLocalizeMap.find(key) != Localization::TempLocalizeMap.end()) if (Localization::TempLocalizeMap.find(key) != Localization::TempLocalizeMap.end())
{ {
entry = Localization::TempLocalizeMap[key]; entry = Localization::TempLocalizeMap[key];
} }
else if (Localization::LocalizeMap.find(key) != Localization::LocalizeMap.end()) else if (Localization::LocalizeMap.find(key) != Localization::LocalizeMap.end())
{ {
entry = Localization::LocalizeMap[key]; entry = Localization::LocalizeMap[key];
}
} }
if (!entry || !entry->value) if (!entry || !entry->value)