mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-03 22:27:41 +00:00
refactor(developer): km_core_keyboard_load_from_blob in debugger
Replaces `km_core_keyboard_load` with `km_core_keyboard_load_from_blob`. Fixes: #12690 Cherry-pick: #12711
This commit is contained in:
parent
8492b12fdb
commit
249428db7b
2 changed files with 26 additions and 3 deletions
|
|
@ -37,6 +37,8 @@ type
|
|||
implementation
|
||||
|
||||
uses
|
||||
System.Classes,
|
||||
|
||||
KeymanPaths;
|
||||
|
||||
{ TDebugCore }
|
||||
|
|
@ -44,6 +46,9 @@ uses
|
|||
constructor TDebugCore.Create(const Filename: string; EnableDebug: Boolean);
|
||||
var
|
||||
status: km_core_status;
|
||||
fs: TFileStream;
|
||||
Buffer: Pointer;
|
||||
BufferSize: NativeInt;
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
|
|
@ -52,7 +57,23 @@ begin
|
|||
FKeyboard := nil;
|
||||
FState := nil;
|
||||
|
||||
status := km_core_keyboard_load(PChar(FileName), FKeyboard);
|
||||
Buffer := nil;
|
||||
try
|
||||
fs := TFileStream.Create(Filename, fmOpenRead or fmShareDenyWrite);
|
||||
try
|
||||
BufferSize := fs.Size;
|
||||
Buffer := AllocMem(BufferSize);
|
||||
if fs.Read(Buffer^, BufferSize) <> BufferSize then
|
||||
raise EDebugCore.Create('Unable to start debugger -- failed to read file from disk');
|
||||
finally
|
||||
fs.Free;
|
||||
end;
|
||||
|
||||
status := km_core_keyboard_load_from_blob(PChar(FileName), Buffer, BufferSize, FKeyboard);
|
||||
finally
|
||||
FreeMem(Buffer);
|
||||
end;
|
||||
|
||||
if status <> KM_CORE_STATUS_OK then
|
||||
raise EDebugCore.CreateFmt('Unable to start debugger -- keyboard load failed with error %x', [Ord(status)]);
|
||||
|
||||
|
|
|
|||
|
|
@ -245,8 +245,10 @@ type
|
|||
|
||||
pkm_core_keyboard_attrs = ^km_core_keyboard_attrs;
|
||||
|
||||
function km_core_keyboard_load(
|
||||
kb_path: km_core_path_name;
|
||||
function km_core_keyboard_load_from_blob(
|
||||
kb_name: km_core_path_name;
|
||||
blob: Pointer;
|
||||
blob_size: NativeUint;
|
||||
var keyboard: pkm_core_keyboard
|
||||
): km_core_status; cdecl; external keymancore delayed;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue