Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 16 total
Thread Stack overflow
Wed, Jun 26 2013 4:13 PMPermanent Link

Ronald

Hi,

I tried to create my own component, based on a TCustompanel. If I create an
instance of my component I get a stackoverflow error (the error is in Duth,
so I hope the translation is correct).
This is my (very) basic source of the component, what is wrong withit?

unit cells;

interface

uses WebCore,WebCtrls;

type
TCell = class(TCustomPanel)
  private
  public
  constructor Create(AOwner: TComponent); override;
  destructor Destroy; override;
  end;

implementation

constructor TCell.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;


destructor TCell.Destroy;
begin
inherited Destroy;
end;

end.

Thanks,
Ronald
Thu, Jun 27 2013 3:30 AMPermanent Link

Mark Brooks

Slikware

Avatar

When do you get the stack overflow?
Thu, Jun 27 2013 3:35 AMPermanent Link

Ronald

If I create an instance of TCell:

procedure TForm1.Form1Create(Sender: TObject);
begin
aCell:=TCell.Create(Self);
aCell.Left:=100;
aCell.Top:=100;
aCell.Show;
end;

If I comment this out, it works fine.

"Mark Brooks" schreef in bericht
news:3616E07B-11CA-44A8-BA92-E0CC6B1D327D@news.elevatesoft.com...

When do you get the stack overflow?
Thu, Jun 27 2013 3:37 AMPermanent Link

Ronald

If I translate the error more accurate it says:

"Insufficient stack space"

"Mark Brooks" schreef in bericht
news:3616E07B-11CA-44A8-BA92-E0CC6B1D327D@news.elevatesoft.com...

When do you get the stack overflow?
Thu, Jun 27 2013 4:12 AMPermanent Link

Matthew Jones

Use Chrome to open it, press F12 to get the debug options, access the source tab
(IIRC), and find the Form1Create (Ctrl-F works). Then put a breakpoint on it. Now
open the page again, and step through it. You will see what it is actually doing,
and how the stack is growing.

/Matthew Jones/
Thu, Jun 27 2013 4:22 AMPermanent Link

Mark Brooks

Slikware

Avatar

>>procedure TForm1.Form1Create(Sender: TObject);
>>begin
>>aCell:=TCell.Create(Self);
>>aCell.Left:=100;
>>aCell.Top:=100;
>>aCell.Show;
>>end;

Are you able to put this code into a button press rather than the FormCreate?
Does the same problem occur?
Thu, Jun 27 2013 4:48 AMPermanent Link

Walter Matte

Tactical Business Corporation


>>procedure TForm1.Form1Create(Sender: TObject);
>>begin
>>aCell:=TCell.Create(Self);
>>aCell.Left:=100;
>>aCell.Top:=100;
>>aCell.Show;
>>end;

I believe EWB behaves differently that Delphi.  In the FormCreate  "Self" (the form object) has not yet been initialized.  

See:

http://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_general&page=1&msg=852#852


So try

procedure TForm1.Form1Create(Sender: TObject);
begin
aCell:=TCell.Create(Form1);       //  <<<<<<<<<
aCell.Left:=100;
aCell.Top:=100;
aCell.Show;
end;

Walter
Thu, Jun 27 2013 4:48 AMPermanent Link

Mark Brooks

Slikware

Avatar

Mark Brooks wrote:

>>procedure TForm1.Form1Create(Sender: TObject);
>>begin
>>aCell:=TCell.Create(Self);
>>aCell.Left:=100;
>>aCell.Top:=100;
>>aCell.Show;
>>end;

>>Are you able to put this code into a button press rather than the FormCreate?
>>Does the same problem occur?

And, what happens if you remove the call to the Show method?
Thu, Jun 27 2013 4:52 AMPermanent Link

Mark Brooks

Slikware

Avatar

>>I believe EWB behaves differently that Delphi.  In the FormCreate  "Self" (the form object) has not yet been >>initialized.  

>>See:

>>http://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_general&page=1&msg=852#852

I thought that too, however I think Tim may have fixed this, primarily because my code uses "Self" in this scenario all over the place and it works just fine. I am running 1.02B1. Nonetheless, certainly worth a check.
Thu, Jun 27 2013 5:01 AMPermanent Link

Ronald

I get the same error if I put the code under a button and replacing Self
with Form1 does not solve the problem either.

"Mark Brooks" schreef in bericht
news:BF20D6B8-5112-4485-B779-E3D82EAFE07B@news.elevatesoft.com...

Mark Brooks wrote:

>>procedure TForm1.Form1Create(Sender: TObject);
>>begin
>>aCell:=TCell.Create(Self);
>>aCell.Left:=100;
>>aCell.Top:=100;
>>aCell.Show;
>>end;

>>Are you able to put this code into a button press rather than the
>>FormCreate?
>>Does the same problem occur?

And, what happens if you remove the call to the Show method?
Page 1 of 2Next Page »
Jump to Page:  1 2
Image