Lazarus

Programming => LCL => Topic started by: sirharlekin on September 17, 2013, 11:48:35 am

Title: Error:Dynamic closing of TFrame
Post by: sirharlekin on September 17, 2013, 11:48:35 am
Hi all,
I've the following problem:
- When I close a TFrame with the following code under Windows, I get an SIG error!
- Under Linux it works perfect.

uses
  Classes, SysUtils, FileUtil, Forms, Controls, ExtCtrls, ComCtrls, Buttons,
  ActnList, StdCtrls;

type
  TModuleFrame = class(TFrame)
    Close: TAction;
    Actionlist: TActionList;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Menubar: TToolBar;
    Toppanel: TPanel;
    Leftpanel: TPanel;
    procedure BitBtn1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

implementation

{$R *.lfm}

procedure TModuleFrame.BitBtn1Click(Sender: TObject);
begin
  self.Free;
end;

end.         

Question:
- Is this a knowing bug or is ther something wrong in my code?
- What's the workaround?
Title: Re: Error:Dynamic closing of TFrame
Post by: Bart on September 17, 2013, 11:57:50 am
Destroying an object in an event (of an object owned by said object) might not be such a good idea.

Bart
Title: Re: Error:Dynamic closing of TFrame
Post by: sirharlekin on September 17, 2013, 12:42:22 pm
Hi Bart,
thanks for youre response, but do you have a solution for this problem?

Michael
Title: Re: Error:Dynamic closing of TFrame
Post by: taazz on September 17, 2013, 12:51:09 pm
call release (it exists in the forms I'm not about the frames) or use the application.AsyncCall Mechanism to class it after the event is finished executing, although this reminds of a bug I encountered in past that had to do with the use of freeThenNill instead of FreeanAndNil procedures in the library I think that it has been patched already but you should check to see which one is used when the owned objects are destroyed inside the frame's destruction process to make sure.
Title: Re: Error:Dynamic closing of TFrame
Post by: Martin_fr on September 17, 2013, 12:59:16 pm
self.hide
application.releaseComponent(self)

or very similar
TinyPortal © 2005-2018