UPD: Initialize error mode early (issue #473)

(cherry picked from commit 919f3a4e18)
This commit is contained in:
Alexander Koblov 2023-12-20 18:16:40 +03:00
commit af48eb9d23
3 changed files with 36 additions and 16 deletions

View file

@ -4,6 +4,7 @@ program doublecmd;
{.$APPTYPE GUI}
uses
uSystem,
{$IFDEF MSWINDOWS}
uElevation,
{$IFDEF LCLQT5}
@ -105,14 +106,14 @@ var
{$ENDIF}
begin
// Initialize again
uSystem.Initialize;
DCDebug('Starting Double Commander');
// Initialize random number generator
Randomize;
// Disable invalid floating point operation exception
SetExceptionMask(GetExceptionMask + [exInvalidOp, exZeroDivide]);
{$IF DEFINED(NIGHTLY_BUILD)}
InitLineInfo;
AddLineInfoPath(ExtractFileDir(ParamStr(0)));
@ -125,13 +126,10 @@ begin
{$ENDIF}
{$IFDEF MSWINDOWS}
uMyWindows.InitErrorMode;
uMyWindows.FixCommandLineToUTF8;
{$ENDIF}
{$if lcl_fullversion >= 1070000}
Application.Scaled:= True;
{$endif}
// Fix default BidiMode
// see http://bugs.freepascal.org/view.php?id=22044
@ -159,14 +157,12 @@ begin
// Use only current directory separator
AllowDirectorySeparators:= [DirectorySeparator];
{$IF lcl_fullversion >= 093100}
// Disable because we set a few of our own format settings and we don't want
// them to be changed. There's no way currently to react to Application.IntfSettingsChange.
// If in future we move to a Unicode RTL this could be removed.
{$PUSH}{$WARN SYMBOL_PLATFORM OFF}
Application.UpdateFormatSettings := False;
{$POP}
{$ENDIF}
DefaultFormatSettings.ThousandSeparator:= ' ';
{$IFDEF UNIX}
uMyUnix.FixDateTimeSeparators;
@ -222,7 +218,7 @@ begin
Application.CreateForm(TdmComData, dmComData); // common data
Application.CreateForm(TdmHelpManager, dmHelpMgr); // help manager
{$IF DEFINED(LCLGTK2) AND (lcl_fullversion >= 093100)}
{$IF DEFINED(LCLGTK2)}
// LCLGTK2 uses Application.MainForm as the clipboard widget, however our
// MainForm is TfrmHackForm and it never gets realized. GTK2 doesn't
// seem to allow a not realized widget to have clipboard ownership.

31
src/platform/usystem.pas Normal file
View file

@ -0,0 +1,31 @@
unit uSystem;
{$mode objfpc}{$H+}
interface
uses
Math
{$IF DEFINED(MSWINDOWS)}
, Windows
{$ENDIF}
;
procedure Initialize;
implementation
procedure Initialize;
begin
// Disable invalid floating point operation exception
SetExceptionMask(GetExceptionMask + [exInvalidOp, exZeroDivide]);
{$IF DEFINED(MSWINDOWS)}
SetErrorMode(SEM_FAILCRITICALERRORS or SEM_NOOPENFILEERRORBOX);
{$ENDIF}
end;
initialization
Initialize;
end.

View file

@ -176,8 +176,6 @@ procedure CreateShortcut(const Target, Shortcut: String);
}
function ExtractFileAttributes(const FindData: TWin32FindDataW): DWORD;
procedure InitErrorMode;
procedure UpdateEnvironment;
procedure FixCommandLineToUTF8;
@ -1132,11 +1130,6 @@ begin
Result:= FindData.dwFileAttributes;
end;
procedure InitErrorMode;
begin
SetErrorMode(SEM_FAILCRITICALERRORS or SEM_NOOPENFILEERRORBOX);
end;
procedure UpdateEnvironment;
var
dwSize: DWORD;