diff options
-rw-r--r-- | src/corelib/fpgfx.pas | 14 | ||||
-rw-r--r-- | src/corelib/gfxbase.pas | 13 |
2 files changed, 10 insertions, 17 deletions
diff --git a/src/corelib/fpgfx.pas b/src/corelib/fpgfx.pas index 36463457..d7e144c4 100644 --- a/src/corelib/fpgfx.pas +++ b/src/corelib/fpgfx.pas @@ -785,13 +785,7 @@ var i: integer; frm: TfpgWindowBase; begin - for i := FFormList.Count - 1 downto 0 do - begin - frm := TfpgWindowBase(FFormList.Items[i]); - FFormList.Remove(frm); - frm.Free; - end; - FFormList.Free; + DestroyComponents; // while message queue is still active for i := 0 to (fpgNamedFonts.Count - 1) do TNamedFontItem(fpgNamedFonts.Items[i]).Free; @@ -939,10 +933,12 @@ end; procedure TfpgApplication.InternalMsgClose(var msg: TfpgMessageRec); begin - writeln('InternalMsgClose received'); +// writeln('InternalMsgClose received'); if Assigned(msg.Sender) then begin - FFormList.Remove(msg.Sender); + if csDestroying in TComponent(msg.Sender).ComponentState then + Exit; + RemoveComponent(TfpgWindowBase(msg.Sender)); TfpgWindowBase(msg.Sender).Free; end; end; diff --git a/src/corelib/gfxbase.pas b/src/corelib/gfxbase.pas index 125583a2..635d043f 100644 --- a/src/corelib/gfxbase.pas +++ b/src/corelib/gfxbase.pas @@ -412,7 +412,7 @@ type end; - TfpgApplicationBase = class(TObject) + TfpgApplicationBase = class(TComponent) private FMainForm: TfpgWindowBase; FTerminated: boolean; @@ -420,7 +420,6 @@ type function GetFormCount: integer; function GetTopModalForm: TfpgWindowBase; protected - FFormList: TList; FOnIdle: TNotifyEvent; FIsInitialized: Boolean; FModalFormStack: TList; @@ -1860,19 +1859,18 @@ end; constructor TfpgApplicationBase.Create(const AParams: string); begin - inherited Create; + inherited Create(nil); FModalFormStack := TList.Create; - FFormList := TList.Create; end; function TfpgApplicationBase.GetFormCount: integer; begin - Result := FFormList.Count; + Result := ComponentCount; end; function TfpgApplicationBase.GetForm(Index: Integer): TfpgWindowBase; begin - Result := TfpgWindowBase(FFormList.Items[Index]); + Result := TfpgWindowBase(Components[Index]); end; function TfpgApplicationBase.GetFontFaceList: TStringList; @@ -1915,8 +1913,7 @@ procedure TfpgApplicationBase.CreateForm(AFormClass: TComponentClass; var AForm: TfpgWindowBase); begin try - AForm := TfpgWindowBase(AFormClass.Create(nil)); - FFormList.Add(AForm); + AForm := TfpgWindowBase(AFormClass.Create(self)); if FMainForm = nil then FMainForm := AForm; except |