Core: Use a shared_ptr for i18n categories.

This does not make them thread safe, but it reduces the chances of a crash
a bit (see #12594.)
This commit is contained in:
Unknown W. Brackets committed 2020-02-09 07:35:16 -08:00
1 parent a4ba5d4859
commit 5009698cc0
54 files changed
+244 -240

No files matched your search

+4 -4
View File
@@ -233,7 +233,7 @@ UI::EventReturn UIScreen::OnCancel(UI::EventParams &e) {
PopupScreen::PopupScreen(std::string title, std::string button1, std::string button2)
: box_(0), defaultButton_(nullptr), title_(title) {
I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");
if (!button1.empty())
button1_ = di->T(button1.c_str());
if (!button2.empty())
@@ -427,7 +427,7 @@ std::string ChopTitle(const std::string &title) {
UI::EventReturn PopupMultiChoice::HandleClick(UI::EventParams &e) {
restoreFocus_ = HasFocus();
I18NCategory *category = category_ ? GetI18NCategory(category_) : nullptr;
auto category = category_ ? GetI18NCategory(category_) : nullptr;
std::vector<std::string> choices;
for (int i = 0; i < numChoices_; i++) {
@@ -450,7 +450,7 @@ void PopupMultiChoice::Update() {
void PopupMultiChoice::UpdateText() {
if (!choices_)
return;
I18NCategory *category = GetI18NCategory(category_);
auto category = GetI18NCategory(category_);
// Clamp the value to be safe.
if (*value_ < minVal_ || *value_ > minVal_ + numChoices_ - 1) {
valueText_ = "(invalid choice)"; // Shouldn't happen. Should be no need to translate this.
@@ -865,7 +865,7 @@ void ChoiceWithValueDisplay::Draw(UIContext &dc) {
int paddingX = 12;
dc.SetFontStyle(dc.theme->uiFont);
I18NCategory *category = GetI18NCategory(category_);
auto category = GetI18NCategory(category_);
std::ostringstream valueText;
if (translateCallback_ && sValue_) {
valueText << translateCallback_(sValue_->c_str());