From ea5bc8c1552eec7f7077d207196784c545d5eaa9 Mon Sep 17 00:00:00 2001 From: pierre Date: Tue, 22 May 2007 06:59:54 +0000 Subject: [PATCH] * avoid crash if removing several editor windows git-svn-id: trunk@7417 - --- ide/fpmwnd.inc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ide/fpmwnd.inc b/ide/fpmwnd.inc index 656c0353a9..6d93432c4c 100644 --- a/ide/fpmwnd.inc +++ b/ide/fpmwnd.inc @@ -182,6 +182,7 @@ end; procedure TWindowListDialog.HandleEvent(var Event: TEvent); var W: PWindow; + KeePOwner : PGroup; begin case Event.What of evKeyDown : @@ -203,7 +204,22 @@ begin cmDeleteItem : if C^.Count>0 then begin - Message(C^.At(LB^.Focused),evCommand,cmClose,nil); + W:=PWindow(C^.At(LB^.Focused)); + { we need to remove the window from the list + because otherwise + IDEApp.SourceWindowClosed + is called after the object has been freed + but the ListBox.Redraw will still try to + read the title PM } + KeepOwner:=W^.Owner; + if assigned(KeepOwner) then + KeepOwner^.Delete(W); + UpdateList; + { But reinsert it as Close might only + trigger Hide in some cases } + if assigned(KeepOwner) then + KeepOwner^.Insert(W); + Message(W,evCommand,cmClose,nil); UpdateList; ClearEvent(Event); end;