Skip to content

Commit 2135e18

Browse files
committed
Probably fixed problems with allocation/deallocation of std::locale
1 parent 94e0a7a commit 2135e18

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

src/xrCore/Text/StringConversion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ u16 mbhMulti2Wide(wchar_t* WideStr, wchar_t* WidePos, u16 WideStrSize, const cha
131131
return dpos;
132132
}
133133

134-
xr_string StringFromUTF8(const char* in, const std::locale& locale /*= std::locale("")*/)
134+
xr_string StringFromUTF8(const char* in, const std::locale& locale)
135135
{
136136
using wcvt = std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t>;
137137
auto wstr = wcvt{}.from_bytes(in);
@@ -140,7 +140,7 @@ xr_string StringFromUTF8(const char* in, const std::locale& locale /*= std::loca
140140
return result;
141141
}
142142

143-
xr_string StringToUTF8(const char* in, const std::locale& locale /*= std::locale("")*/)
143+
xr_string StringToUTF8(const char* in, const std::locale& locale)
144144
{
145145
using wcvt = std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t>;
146146
std::wstring wstr(xr_strlen(in), L'\0');

src/xrCore/Text/StringConversion.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ IC bool IsAlphaCharacter(wchar_t wc)
3030
((wc >= 0xFF21) && (wc <= 0xFF3A)) || ((wc >= 0xFF41) && (wc <= 0xFF5A)));
3131
}
3232

33-
XRCORE_API xr_string StringFromUTF8(const char* string, const std::locale& locale = std::locale(""));
34-
XRCORE_API xr_string StringToUTF8(const char* string, const std::locale& locale = std::locale(""));
33+
XRCORE_API xr_string StringFromUTF8(const char* string, const std::locale& locale);
34+
XRCORE_API xr_string StringToUTF8(const char* string, const std::locale& locale);

src/xrEngine/edit_actions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void type_pair::on_key_press(line_edit_control* const control)
7070
{
7171
case SDL_TEXTINPUT:
7272
{
73-
const std::locale locale("");
73+
static std::locale locale("");
7474
auto str = StringFromUTF8(event.text.text, locale);
7575

7676
if (std::isalpha(str[0], locale) || str[0] == char(-1)) // "я" = -1

src/xrEngine/xr_input.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,10 @@ pcstr KeyToMouseButtonName(const int dik)
195195
bool CInput::get_dik_name(int dik, LPSTR dest_str, int dest_sz)
196196
{
197197
xr_string keyname;
198+
static std::locale locale("");
198199

199200
if (dik < SDL_NUM_SCANCODES)
200-
keyname = StringFromUTF8(SDL_GetKeyName(SDL_GetKeyFromScancode((SDL_Scancode)dik)));
201+
keyname = StringFromUTF8(SDL_GetKeyName(SDL_GetKeyFromScancode((SDL_Scancode)dik)), locale);
201202
else
202203
keyname = KeyToMouseButtonName(dik);
203204

0 commit comments

Comments
 (0)