From 3d5506ef3ef493448e2ecc0d92f4455efb02cc50 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Mon, 11 Dec 2023 20:44:53 +0700 Subject: [PATCH] chore(windows): move reportExceptions check in exception handler to caller --- .../Keyman.System.KeymanSentryClient.pas | 36 +++++++++++++------ .../tsysinfo/UfrmRemoteExceptionHandler.pas | 21 +---------- 2 files changed, 26 insertions(+), 31 deletions(-) diff --git a/common/windows/delphi/general/Keyman.System.KeymanSentryClient.pas b/common/windows/delphi/general/Keyman.System.KeymanSentryClient.pas index 65ad529f21..470507ce2c 100644 --- a/common/windows/delphi/general/Keyman.System.KeymanSentryClient.pas +++ b/common/windows/delphi/general/Keyman.System.KeymanSentryClient.pas @@ -135,6 +135,7 @@ var {$IF NOT DEFINED(CONSOLE)} ApplicationTitle, CommandLine: string; tsysinfopath, enginepath: string; + keyman_root: string; {$ENDIF} begin if EventType = scetException then @@ -176,23 +177,37 @@ begin ApplicationTitle := AppID; {$ENDIF} - CommandLine := Format('-c "%s" "%s" "%s" "%s" "%s" "%s"', [ + CommandLine := Format('-c "%s" "%s" "%s" "%s" "%s" "%s" %s', [ IfThen(EventID = '', '_', EventID), IfThen(ApplicationTitle = '', ChangeFileExt(ExtractFileName(ParamStr(0)),''), ApplicationTitle), AppID, ProjectName, EventClassName, - StringReplace(Message, '"', '""', [rfReplaceAll]) + StringReplace(Message, '"', '""', [rfReplaceAll]), + IfThen(FClient.ReportExceptions, 'report', 'no-report') ]); - try - tsysinfopath := TKeymanPaths.KeymanEngineInstallPath('tsysinfo.exe'); - enginepath := TKeymanPaths.KeymanEngineInstallPath(''); - except - on E:EKeymanPath do - begin - tsysinfopath := ''; - enginepath := ''; + if TKeymanPaths.RunningFromSource(keyman_root) then + begin + enginepath := keyman_root + 'windows\bin\engine'; + tsysinfopath := enginepath + '\tsysinfo.exe'; + end + else if FileExists(ExtractFilePath(ParamStr(0)) + 'tsysinfo\tsysinfo.exe') then + begin + enginepath := ExtractFilePath(ParamStr(0)) + 'tsysinfo'; + tsysinfopath := enginepath + '\tsysinfo.exe'; + end + else + begin + try + tsysinfopath := TKeymanPaths.KeymanEngineInstallPath('tsysinfo.exe'); + enginepath := TKeymanPaths.KeymanEngineInstallPath(''); + except + on E:EKeymanPath do + begin + tsysinfopath := ''; + enginepath := ''; + end; end; end; if (tsysinfopath = '') or not TUtilExecute.Shell(0, tsysinfopath, enginepath, CommandLine) then @@ -314,7 +329,6 @@ end; constructor TKeymanSentryClient.Create(SentryClientClass: TSentryClientClass; AProject: TKeymanSentryClientProject; const ALogger: string; AFlags: TKeymanSentryClientFlags); var - reg: TRegistry; o: TSentryClientOptions; f: TSentryClientFlags; path: string; diff --git a/windows/src/engine/tsysinfo/UfrmRemoteExceptionHandler.pas b/windows/src/engine/tsysinfo/UfrmRemoteExceptionHandler.pas index 7ddc9202c9..8aba48591c 100644 --- a/windows/src/engine/tsysinfo/UfrmRemoteExceptionHandler.pas +++ b/windows/src/engine/tsysinfo/UfrmRemoteExceptionHandler.pas @@ -92,11 +92,9 @@ function RunCrashReportHandler: Boolean; implementation uses - System.Win.Registry, Vcl.Clipbrd, Keyman.System.KeymanSentryClient, - RegistryKeys, Upload_Settings, utilexecute; @@ -124,8 +122,6 @@ function RunCrashReportHandler: Boolean; var frm: TfrmExceptionHandler; crashID, applicationName, applicationID, projectName, eventClassName, eventMessage: string; - reg: TRegistry; - RegKey: string; reportExceptions: Boolean; begin if ParamStr(1) <> '-c' then @@ -137,6 +133,7 @@ begin projectName := ParamStr(5); eventClassName := ParamStr(6); eventMessage := ParamStr(7); + reportExceptions := ParamStr(8) = 'report'; Application.CreateForm(TfrmExceptionHandler, frm); Application.Title := applicationName; @@ -147,22 +144,6 @@ begin frm.EventClassName := eventClassName; frm.EventMessage := eventMessage; - // Load the registry settings for privacy settings - - if projectName = SENTRY_PROJECT_NAME_DESKTOP - then RegKey := SRegKey_KeymanEngine_CU - else RegKey := SRegKey_IDEOptions_CU; - - reg := TRegistry.Create; - try - reportExceptions := - not reg.OpenKeyReadOnly(RegKey) or - not reg.ValueExists(SRegValue_AutomaticallyReportErrors) or - reg.ReadBool(SRegValue_AutomaticallyReportErrors); - finally - reg.Free; - end; - frm.lblText2.Visible := reportExceptions; frm.lblNoPersonal.Visible := reportExceptions; //? frm.lblNotReported.Visible := not reportExceptions;