Fix crash in translations code when no translations are found
Fix another regression in wxTranslations in 3.1.2 and check that the vector of acceptable translations is not empty before using its first element. Closes https://github.com/wxWidgets/wxWidgets/pull/1082 Closes #18299.
This commit is contained in:
committed by
Vadim Zeitlin
parent
14e905858d
commit
80904d1bc7
@@ -1676,9 +1676,9 @@ wxString wxTranslations::GetBestTranslation(const wxString& domain,
|
|||||||
const wxString& msgIdLanguage)
|
const wxString& msgIdLanguage)
|
||||||
{
|
{
|
||||||
const wxArrayString allGoodOnes = GetAcceptableTranslations(domain, msgIdLanguage);
|
const wxArrayString allGoodOnes = GetAcceptableTranslations(domain, msgIdLanguage);
|
||||||
|
wxString best(allGoodOnes.empty() ? wxString() : allGoodOnes[0]);
|
||||||
wxLogTrace(TRACE_I18N, " => using language '%s'", allGoodOnes[0]);
|
wxLogTrace(TRACE_I18N, " => using language '%s'", best);
|
||||||
return allGoodOnes[0];
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxArrayString wxTranslations::GetAcceptableTranslations(const wxString& domain,
|
wxArrayString wxTranslations::GetAcceptableTranslations(const wxString& domain,
|
||||||
|
Reference in New Issue
Block a user