[INPUT] Fix exception on SPI_SETDEFALTINPUTLANG (#6043)

Follow-up to #4666. Fix an abnormal termination at setting the default language.
- pCurrent was NULL at the scene. Don't use it there for SPI_SETDEFALTINPUTLANG.
- Save the default keyboard layout. Use it.
CORE-11700, CORE-13244, CORE-18364
This commit is contained in:
Katayama Hirofumi MZ 2023-11-27 20:25:58 +09:00 committed by GitHub
parent fb642f727f
commit f7a4c26322
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -385,6 +385,7 @@ InputList_Process(VOID)
DWORD dwNumber;
BOOL bRet = FALSE;
HKEY hPreloadKey, hSubstKey;
HKL hDefaultKL = NULL;
if (!InputList_PrepareUserRegistry(&hPreloadKey, &hSubstKey))
{
@ -442,6 +443,9 @@ InputList_Process(VOID)
/* Activate the DEFAULT entry */
ActivateKeyboardLayout(pCurrent->hkl, KLF_RESET);
/* Save it */
hDefaultKL = pCurrent->hkl;
break;
}
}
@ -467,7 +471,7 @@ InputList_Process(VOID)
}
/* Change the default keyboard language */
if (SystemParametersInfoW(SPI_SETDEFAULTINPUTLANG, 0, &pCurrent->hkl, 0))
if (SystemParametersInfoW(SPI_SETDEFAULTINPUTLANG, 0, &hDefaultKL, 0))
{
DWORD dwRecipients = BSM_ALLDESKTOPS | BSM_APPLICATIONS;
@ -475,7 +479,7 @@ InputList_Process(VOID)
&dwRecipients,
WM_INPUTLANGCHANGEREQUEST,
INPUTLANGCHANGE_SYSCHARSET,
(LPARAM)pCurrent->hkl);
(LPARAM)hDefaultKL);
}
/* Retry to delete (in case of failure to delete the default keyboard) */