mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-25 01:37:42 +00:00
Fixes #5091. If the user has a default language that is not a minimal BCP47 tag, such as `zh-Hans-CN` vs `zh-CN`, or if the default language does not have a mapping in our `TLanguageCodeUtils.TranslateWindowsLanguagesToBCP47` function, then kmshell would crash on install of a keyboard that had no language metadata specified (i.e. neither legacy metadata in .kmx nor modern metadata in .kmp). This crash arose because the elevated instance of kmshell would install a local-machine reference to `zh-CN` (as it back-translated from a LangID), but the current user install would look for `zh-Hans-CN`, read from the Windows registry `HKCU\Control Panel\International\User Profile`. To further complicate matters, it is possible for the current user to have a different default language than the elevated user on the machine. Keyman was assuming that the default language was the same in both cases. This fix passes in the current user's default BCP47 and LangID to the elevated portion of the keyboard install, so we can guarantee that keyboard install which needs to use the default language, actually installs for the current user's actual language code, and not a canonicalized version (or a totally different code in the case of elevation to an alternate admin user account).
117 lines
3 KiB
ObjectPascal
117 lines
3 KiB
ObjectPascal
(*
|
|
Name: keymancontext
|
|
Copyright: Copyright (C) SIL International.
|
|
Documentation:
|
|
Description:
|
|
Create Date: 1 Aug 2006
|
|
|
|
Modified Date: 12 Mar 2010
|
|
Authors: mcdurdin
|
|
Related Files:
|
|
Dependencies:
|
|
|
|
Bugs:
|
|
Todo:
|
|
Notes:
|
|
History: 01 Aug 2006 - mcdurdin - Add Control property
|
|
27 Mar 2008 - mcdurdin - Add Languages and Options access
|
|
12 Mar 2010 - mcdurdin - I2230 - Resolve crashes due to incorrect reference counting
|
|
*)
|
|
unit keymancontext;
|
|
|
|
interface
|
|
|
|
uses
|
|
comobj,
|
|
keymanapi_tlb,
|
|
internalinterfaces,
|
|
utilkeymancontrol;
|
|
|
|
type
|
|
TKeymanContext = class
|
|
private
|
|
FKeyman: TObject;
|
|
FController: TKeymanController;
|
|
FDefaultBCP47: string;
|
|
FDefaultLangID: Integer;
|
|
function GetErrors: IIntKeymanErrors;
|
|
function GetKeyboards: IIntKeymanKeyboardsInstalled;
|
|
function GetPackages: IIntKeymanPackagesInstalled;
|
|
function GetSystemInfo: IIntKeymanSystemInfo;
|
|
function GetControl: IIntKeymanControl;
|
|
function GetOptions: IIntKeymanOptions;
|
|
function GetLanguages: IIntKeymanLanguages;
|
|
public
|
|
constructor Create(AKeyman: TObject);
|
|
destructor Destroy; override;
|
|
property Errors: IIntKeymanErrors read GetErrors;
|
|
property Keyboards: IIntKeymanKeyboardsInstalled read GetKeyboards;
|
|
property Languages: IIntKeymanLanguages read GetLanguages;
|
|
property Options: IIntKeymanOptions read GetOptions;
|
|
property Packages: IIntKeymanPackagesInstalled read GetPackages;
|
|
property SystemInfo: IIntKeymanSystemInfo read GetSystemInfo;
|
|
property Control: IIntKeymanControl read GetControl;
|
|
property Controller: TKeymanController read FController;
|
|
|
|
property DefaultBCP47: string read FDefaultBCP47 write FDefaultBCP47;
|
|
property DefaultLangID: Integer read FDefaultLangID write FDefaultLangID;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
SysUtils, keyman_implementation;
|
|
|
|
{ TKeymanContext }
|
|
|
|
constructor TKeymanContext.Create(AKeyman: TObject);
|
|
begin
|
|
inherited Create;
|
|
FKeyman := AKeyman;
|
|
FController := TKeymanController.Create(FKeyman);
|
|
end;
|
|
|
|
destructor TKeymanContext.Destroy;
|
|
begin
|
|
FreeAndNil(FController);
|
|
inherited Destroy;
|
|
end;
|
|
|
|
function TKeymanContext.GetControl: IIntKeymanControl;
|
|
begin
|
|
Result := (FKeyman as TKeyman).Control;
|
|
end;
|
|
|
|
function TKeymanContext.GetErrors: IIntKeymanErrors;
|
|
begin
|
|
Result := (FKeyman as TKeyman).Errors;
|
|
end;
|
|
|
|
function TKeymanContext.GetKeyboards: IIntKeymanKeyboardsInstalled;
|
|
begin
|
|
Result := (FKeyman as TKeyman).Keyboards;
|
|
end;
|
|
|
|
function TKeymanContext.GetLanguages: IIntKeymanLanguages;
|
|
begin
|
|
Result := (FKeyman as TKeyman).Languages;
|
|
end;
|
|
|
|
function TKeymanContext.GetOptions: IIntKeymanOptions;
|
|
begin
|
|
Result := (FKeyman as TKeyman).Options;
|
|
end;
|
|
|
|
function TKeymanContext.GetPackages: IIntKeymanPackagesInstalled;
|
|
begin
|
|
Result := (FKeyman as TKeyman).Packages;
|
|
end;
|
|
|
|
function TKeymanContext.GetSystemInfo: IIntKeymanSystemInfo;
|
|
begin
|
|
Result := (FKeyman as TKeyman).SystemInfo;
|
|
end;
|
|
|
|
end.
|
|
|
|
|