X11 msgbox: try to protect the existing setlocale() state.
This commit is contained in:
parent
2c1f08ae4b
commit
f34e7b4ce0
1 changed files with 17 additions and 2 deletions
|
@ -654,14 +654,23 @@ X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
SDL_MessageBoxDataX11 data;
|
SDL_MessageBoxDataX11 data;
|
||||||
|
char *origlocale;
|
||||||
|
|
||||||
SDL_zero(data);
|
SDL_zero(data);
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
|
||||||
|
|
||||||
if ( !SDL_X11_LoadSymbols() )
|
if ( !SDL_X11_LoadSymbols() )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
origlocale = setlocale(LC_ALL, NULL);
|
||||||
|
if (origlocale != NULL) {
|
||||||
|
origlocale = SDL_strdup(origlocale);
|
||||||
|
if (origlocale == NULL) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
|
}
|
||||||
|
|
||||||
/* This code could get called from multiple threads maybe? */
|
/* This code could get called from multiple threads maybe? */
|
||||||
XInitThreads();
|
XInitThreads();
|
||||||
|
|
||||||
|
@ -681,6 +690,12 @@ X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||||
}
|
}
|
||||||
|
|
||||||
X11_MessageBoxShutdown( &data );
|
X11_MessageBoxShutdown( &data );
|
||||||
|
|
||||||
|
if (origlocale) {
|
||||||
|
setlocale(LC_ALL, origlocale);
|
||||||
|
SDL_free(origlocale);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue