Fix for app crash if Windows installed language not supported. Fixes issue #44.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Platform main support module for Windows.
|
||||
*
|
||||
* Version: @(#)win.c 1.0.18 2018/09/02
|
||||
* Version: @(#)win.c 1.0.19 2018/09/03
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -188,7 +188,7 @@ int WINAPI
|
||||
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
|
||||
{
|
||||
wchar_t **argw = NULL;
|
||||
int argc, i;
|
||||
int argc, i, lang;
|
||||
|
||||
/* Set this to the default value (windowed mode). */
|
||||
vid_fullscreen = 0;
|
||||
@@ -197,7 +197,22 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
|
||||
hInstance = hInst;
|
||||
|
||||
/* First, set our (default) language. */
|
||||
lang_id = (int)GetUserDefaultUILanguage();
|
||||
lang = (int)GetUserDefaultUILanguage();
|
||||
|
||||
/*
|
||||
* Set the initial active language for this application.
|
||||
*
|
||||
* We must do this early, because if we are on a localized
|
||||
* Windows system, we must have the language set up so the
|
||||
* "pc_setup" phase (config file etc) can display error
|
||||
* messages... *cough*
|
||||
*/
|
||||
if (! plat_set_language(lang)) {
|
||||
/* That did not work. Revert back to default and try again. */
|
||||
lang = lang_id;
|
||||
(void)plat_set_language(lang);
|
||||
}
|
||||
lang_id = lang;
|
||||
|
||||
/* Initialize the version data. CrashDump needs it early. */
|
||||
pc_version("Windows");
|
||||
@@ -226,7 +241,11 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
|
||||
plat_console(0);
|
||||
|
||||
/* Set the active language for this application. */
|
||||
plat_set_language(lang_id);
|
||||
if (! plat_set_language(lang_id)) {
|
||||
/* That did not work. Revert back to default and try again. */
|
||||
lang_id = 0x0409;
|
||||
(void)plat_set_language(lang_id);
|
||||
}
|
||||
|
||||
/* Create a mutex for the video handler. */
|
||||
hBlitMutex = CreateMutex(NULL, FALSE, MUTEX_NAME);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Handle language support for the platform.
|
||||
*
|
||||
* Version: @(#)win_lang.c 1.0.5 2018/08/26
|
||||
* Version: @(#)win_lang.c 1.0.6 2018/09/03
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -351,7 +351,7 @@ lang_index(int id)
|
||||
|
||||
|
||||
/* Set (or re-set) the language for the application. */
|
||||
void
|
||||
int
|
||||
plat_set_language(int id)
|
||||
{
|
||||
LANGID lang;
|
||||
@@ -370,14 +370,14 @@ plat_set_language(int id)
|
||||
|
||||
/* Set new language ID if not already set. */
|
||||
lang = MAKELANGID(id, dwSubLangID);
|
||||
if (lang_curr == lang) return;
|
||||
if (lang_curr == lang) return(1);
|
||||
|
||||
/* Find language in the table. */
|
||||
for (ptr = languages; ptr != NULL; ptr = ptr->next)
|
||||
if (ptr->id == id) break;
|
||||
if (ptr == NULL) {
|
||||
pclog("UI: language not supported, not setting.\n");
|
||||
return;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Do we need to unload a resource DLL? */
|
||||
@@ -393,7 +393,7 @@ plat_set_language(int id)
|
||||
LOAD_LIBRARY_AS_DATAFILE);
|
||||
if (lang_handle == NULL) {
|
||||
pclog("UI: unable to load resource DLL '%ls' !\n", ptr->dll);
|
||||
return;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,6 +409,9 @@ plat_set_language(int id)
|
||||
/* This can be removed, it no longer works since Vista+ */
|
||||
lcid = MAKELCID(id, SORT_DEFAULT);
|
||||
SetThreadLocale(lcid);
|
||||
|
||||
/* All is good, language set! */
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user