Fixing crash messages in stdout after closing doublecmd.

This commit is contained in:
Peter P. Lupo 2026-06-20 00:58:58 -04:00
commit 3fbb7161fa
2 changed files with 29 additions and 2 deletions

View file

@ -6303,10 +6303,14 @@ begin
Page.Terminal.Width := 400;
Page.Terminal.Height := 176;
Page.Terminal.ShowHint := False;
// Notify Page when Terminal is freed externally (e.g. parent panel
// destroyed during shutdown) so Page can nil its reference.
Page.Terminal.FreeNotification(Page);
FontOptionsToFont(gFonts[dcfConsole], Page.Terminal.Font);
Page.PtyDevice := TPtyDevice.Create(Self);
Page.PtyDevice.FreeNotification(Page);
Page.Terminal.PtyDevice := Page.PtyDevice;
Page.Terminal.Parent := AParent;

View file

@ -87,6 +87,7 @@ type
procedure DoActivate;
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure PaintWindow(DC: HDC); override;
{$IF DEFINED(LCLWIN32)}
procedure RealSetText(const AValue: TCaption); override;
@ -247,11 +248,33 @@ end;
destructor TFileViewPage.Destroy;
begin
if Assigned(FTerminal) then FTerminal.Free;
if Assigned(FPtyDevice) then FPtyDevice.Free;
// Terminal and PtyDevice may already be freed if their parent panel was
// destroyed before us (the Notification override nils the references).
if Assigned(FPtyDevice) then
begin
FPtyDevice.RemoveFreeNotification(Self);
FreeAndNil(FPtyDevice);
end;
if Assigned(FTerminal) then
begin
FTerminal.RemoveFreeNotification(Self);
FreeAndNil(FTerminal);
end;
inherited Destroy;
end;
procedure TFileViewPage.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if Operation = opRemove then
begin
if AComponent = FTerminal then
FTerminal := nil
else if AComponent = FPtyDevice then
FPtyDevice := nil;
end;
end;
{$IF DEFINED(LCLWIN32)}
procedure TFileViewPage.RealSetText(const AValue: TCaption);
begin