ui: Don't use facets of destructed locales.

This commit is contained in:
Vas Crabb 2023-05-01 02:37:28 +10:00
parent 95fc84a22c
commit c649fa82fd
8 changed files with 19 additions and 11 deletions

View File

@ -1106,11 +1106,11 @@ end
end end
if version >= 130000 then if version >= 130000 then
buildoptions_c { buildoptions_c {
"-Wno-dangling-pointer", "-Wno-error=dangling-pointer",
} }
buildoptions_cpp { buildoptions_cpp {
"-Wno-dangling-reference", "-Wno-error=dangling-reference",
"-Wno-dangling-pointer", "-Wno-error=dangling-pointer",
"-Wno-xor-used-as-pow", "-Wno-xor-used-as-pow",
} }
end end

View File

@ -321,7 +321,8 @@ void menu_add_change_folder::populate()
} }
// sort // sort
std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t> >(std::locale()); std::locale const lcl;
std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t> >(lcl);
std::sort( std::sort(
dirnames.begin(), dirnames.begin(),
dirnames.end(), dirnames.end(),

View File

@ -420,7 +420,8 @@ void menu_file_selector::populate()
if (m_entrylist.size() > first) if (m_entrylist.size() > first)
{ {
// sort the menu entries // sort the menu entries
std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t> >(std::locale()); std::locale const lcl;
std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t> >(lcl);
std::sort( std::sort(
m_entrylist.begin() + first, m_entrylist.begin() + first,
m_entrylist.end(), m_entrylist.end(),

View File

@ -58,7 +58,8 @@ inifile_manager::inifile_manager(ui_options &options)
} }
} }
} }
std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t>>(std::locale()); std::locale const lcl;
std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t> >(lcl);
std::stable_sort( std::stable_sort(
m_ini_index.begin(), m_ini_index.begin(),
m_ini_index.end(), m_ini_index.end(),
@ -132,7 +133,8 @@ void inifile_manager::init_category(std::string &&filename, util::core_file &fil
} }
if (!index.empty()) if (!index.empty())
{ {
std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t>>(std::locale()); std::locale const lcl;
std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t> >(lcl);
std::stable_sort( std::stable_sort(
index.begin(), index.begin(),
index.end(), index.end(),

View File

@ -479,7 +479,8 @@ void menu_crosshair::populate()
if ((length > 4) && core_filename_ends_with(dir->name, ".png")) if ((length > 4) && core_filename_ends_with(dir->name, ".png"))
m_pics.emplace_back(dir->name, length - 4); m_pics.emplace_back(dir->name, length - 4);
} }
std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t>>(std::locale()); std::locale const lcl;
std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t> >(lcl);
std::stable_sort( std::stable_sort(
m_pics.begin(), m_pics.begin(),
m_pics.end(), m_pics.end(),

View File

@ -223,7 +223,8 @@ public:
} }
// sort array // sort array
std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t> >(std::locale()); std::locale const lcl;
std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t> >(lcl);
auto const compare_names = auto const compare_names =
[&coll] (std::string const &x, std::string const &y) -> bool [&coll] (std::string const &x, std::string const &y) -> bool
{ {

View File

@ -258,7 +258,8 @@ void menu_software_list::populate()
} }
else else
{ {
std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t>>(std::locale()); std::locale const lcl;
std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t> >(lcl);
m_entrylist.sort( m_entrylist.sort(
[&coll] (entry_info const &e1, entry_info const &e2) -> bool [&coll] (entry_info const &e1, entry_info const &e2) -> bool
{ {

View File

@ -139,7 +139,8 @@ void system_list::do_cache_data(std::string const &datpath, std::string const &t
} }
// sort drivers and notify // sort drivers and notify
std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t> >(std::locale()); std::locale const lcl;
std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t> >(lcl);
auto const compare_names = auto const compare_names =
[&coll] (std::wstring const &wx, std::wstring const &wy) -> bool [&coll] (std::wstring const &wx, std::wstring const &wy) -> bool
{ {