Skip to content

Commit

Permalink
Avoid flickering the main window when wsl is not installed.
Browse files Browse the repository at this point in the history
Checking whether wsl installed is in the main window, so the window
must be created and shown anyway even if wsl is missing.
This patch moves the checking right in the application initialization
before the window will be created.
  • Loading branch information
skoro committed Nov 27, 2021
1 parent 413b93e commit 0aef61b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
14 changes: 0 additions & 14 deletions src/mainwindow.pas
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ TWslGuiToolMainWindow = class(TForm)
IconListToolbar: TImageList;
ToolBar1: TToolBar;
ToolButtonRun: TToolButton;
procedure CheckIfWslIsInstalledExecute(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormHide(Sender: TObject);
Expand Down Expand Up @@ -235,18 +234,6 @@ function NumberItemSelected(List: TListView): integer;
end;
end;

procedure TWslGuiToolMainWindow.CheckIfWslIsInstalledExecute(Sender: TObject);
begin
if not WslCommandLine.IsWslInstalled()
then begin
Application.MessageBox(
'WSL seems to be not installed!',
'Error',
MB_OK + MB_ICONERROR);
Application.Terminate;
end;
end;

procedure TWslGuiToolMainWindow.FormCreate(Sender: TObject);
begin
BackgroundProcessProgressBar := TBackgroundProcessProgressBar.Create(Self);
Expand All @@ -258,7 +245,6 @@ procedure TWslGuiToolMainWindow.FormCreate(Sender: TObject);

StatusbarImageIndex := -1;
StatusbarMessage := '';
Self.CheckIfWslIsInstalledExecute(Sender);
end;

procedure TWslGuiToolMainWindow.FormDestroy(Sender: TObject);
Expand Down
19 changes: 16 additions & 3 deletions src/wslguitool.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,30 @@
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, MainWindow, WslApi, WslCommandLine, WslRegistry, ApplicationInfo,
Forms, LCLType, MainWindow, WslApi, WslCommandLine, WslRegistry, ApplicationInfo,
AboutWindow, DistributionPropertiesWindow, ImportDistributionWindow,
RunCommandWithUserWindow, PromptWindow, BackgroundProcessProgressBar, ProcessResultDisplay;

{$R *.res}

begin
RequireDerivedFormResource:=True;

Application.Scaled:=True;
Application.Initialize;
Application.CreateForm(TWslGuiToolMainWindow, WslGuiToolMainWindow);
Application.Run;

if WslCommandLine.IsWslInstalled() then
begin
Application.CreateForm(TWslGuiToolMainWindow, WslGuiToolMainWindow);
Application.Run;
end
else begin
Application.MessageBox(
'WSL seems to be not installed!',
'Error',
MB_OK + MB_ICONERROR
);
Application.Terminate;
end;
end.

0 comments on commit 0aef61b

Please sign in to comment.