Recent

Author Topic: Error:Dynamic closing of TFrame  (Read 1771 times)

sirharlekin

  • Newbie
  • Posts: 4
Error:Dynamic closing of TFrame
« 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?

Bart

  • Hero Member
  • *****
  • Posts: 3539
    • Bart en Mariska's Webstek
Re: Error:Dynamic closing of TFrame
« Reply #1 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

sirharlekin

  • Newbie
  • Posts: 4
Re: Error:Dynamic closing of TFrame
« Reply #2 on: September 17, 2013, 12:42:22 pm »
Hi Bart,
thanks for youre response, but do you have a solution for this problem?

Michael

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: Error:Dynamic closing of TFrame
« Reply #3 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.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5699
    • wiki
Re: Error:Dynamic closing of TFrame
« Reply #4 on: September 17, 2013, 12:59:16 pm »
self.hide
application.releaseComponent(self)

or very similar