Forum > LCL

[SOLVED] Setting TLabel caption causes crash at run

(1/1)

GeneCode:
This is weird.
I have a TValueListEditor and Event OnSelection setup.

Here is the onEvent function:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.AppTableSelection(Sender: TObject; aCol, aRow: Integer);begin  WriteLn(IntTostr(aRow));  WriteLn(appsArray[aRow]);end;
Work ok, when I select a row on the ValueListEditor, I get the row index and the value of that array at that index. But when I input a TLabel with name appLabel, and I add the code to set the text,


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---appLabel.Caption := 'test'; in the event method above, it immediately crash when run.

ERROR:
Project *** raises exception class External SIGSEGV
In file control.inc

Any idea why?  %)

GeneCode:
Ok found the issue. lol

Turns out this event is called at formcreate, and that time the label is not created yet (i guess).
So i use a boolean flag to set to true only after formActivate.

And in the onSelection event, do (pseudocode)

if (canRun) {
  set label text.
}

Then it is ok and no more crashing and works as expected.

Navigation

[0] Message Index

Go to full version