Avoid accessing GetParentForm if it's already destroyed - hopefully fixes issue #1462

This commit is contained in:
Ansgar Becker
2009-11-11 20:20:07 +00:00
parent 8f12ca9400
commit 66d80bdeab

View File

@ -5513,6 +5513,7 @@ procedure TMainForm.SaveListSetup( List: TVirtualStringTree );
var var
i : Byte; i : Byte;
ColWidths, ColsVisible, ColPos, Regname: String; ColWidths, ColsVisible, ColPos, Regname: String;
OwnerForm: TCustomForm;
begin begin
ColWidths := ''; ColWidths := '';
ColsVisible := ''; ColsVisible := '';
@ -5540,8 +5541,15 @@ begin
end; end;
OpenRegistry; OpenRegistry;
Regname := List.Name; Regname := List.Name;
if GetParentForm(List) <> Self then OwnerForm := GetParentForm(List);
Regname := GetParentForm(List).Name + '.' + Regname; if OwnerForm <> Self then begin
// On a windows shutdown, GetParentForm() seems sporadically unable to find the owner form
// In that case we would cause an exception when accessing it. Emergency break in that case.
// See issue #1462
if not Assigned(OwnerForm) then
Exit;
Regname := OwnerForm.Name + '.' + Regname;
end;
MainReg.WriteString( REGPREFIX_COLWIDTHS + Regname, ColWidths ); MainReg.WriteString( REGPREFIX_COLWIDTHS + Regname, ColWidths );
MainReg.WriteString( REGPREFIX_COLSVISIBLE + Regname, ColsVisible ); MainReg.WriteString( REGPREFIX_COLSVISIBLE + Regname, ColsVisible );
MainReg.WriteString( REGPREFIX_COLPOS + Regname, ColPos ); MainReg.WriteString( REGPREFIX_COLPOS + Regname, ColPos );