[Solved] Crash with External:SIGSEGV on set color of TStringGrid.SelectedColumn lazarus / 31-LCL ---------------------------------------------------------------------- saml · 2015-10-30 13:57 Hi, To reproduce 1. Add a TStringGrid to a form in Lazarus. 2. In the events tab, on the event "OnSelectCell", click the "..." button to create an event handler. 3. Add the following line in the newly created event handler code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i StringGrid1.SelectedColumn.Color := $00FFFF; ... so that you get: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.StringGrid1SelectCell(Sender: TObject; aCol, aRow: Integer; var CanSelect: Boolean);begin  StringGrid1.SelectedColumn.Color := $00FFFF;end; 4. Run the program (Press F9). 5. Click on one cell in the grid. 6. Already on start, it crashes with "External:SIGSEGV", on line 10776 in /usr/lib/lazarus/1.0.10/lcl/grids.pas    (Should correspond to this line: https://github.com/alrieckert/lazarus/blob/master/lcl/grids.pas#L11516 ) Code for the above is available here: https://github.com/samuell/lazarus_stringgrid_error Have got the same result on these systems: - Lazarus 1.0.10, Xubuntu 14.04 64 bit - Lazarus 1.4.0, Xubuntu 15.10 64 bit - Lazarus 1.4.0, Windows Server 2003 32bit ---------------------------------------------------------------------- saml · 2015-10-30 14:06 Ok, stupid me ... just changing: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i StringGrid1.SelectedColumn.Color := $00FFFF; ... to: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if StringGrid1.SelectedColumn <> nil then  StringGrid1.SelectedColumn.Color := $00FFFF; ... makes it not crash. But, when is the "SelectedColumn" supposed to get initialized? ---------------------------------------------------------------------- Cyrax · 2015-10-30 14:47 When you click on the column, I assume. ---------------------------------------------------------------------- saml · 2015-10-30 14:57 Quote from: Cyrax on October 30, 2015, 03:47:50 pmWhen you click on the column, I assume. True. It doesn't seem to ever be initialized though. If I add the test for whether it is nil, like above, this code never gets executed. I.e. if I add a ShowMessage ... it is never shown (I mean, like so: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.StringGrid1SelectCell(Sender: TObject; aCol, aRow: Integer;  var CanSelect: Boolean);begin  if StringGrid1.SelectedColumn <> nil then begin    ShowMessage('SelectedColumn was not nil!');    StringGrid1.SelectedColumn.Color := $00FFFF;  end;end;) ---------------------------------------------------------------------- taazz · 2015-10-30 14:59 do you have columns defined in your stringgrid? ---------------------------------------------------------------------- saml · 2015-10-30 15:04 Quote from: taazz on October 30, 2015, 03:59:50 pmdo you have columns defined in your stringgrid? Ah, that's it! I hadn't added any columns in the property inspector, yea  (... I simply thought that they were initialized since the the grid shows borders for a few rows and columns by default). Ok problem solved, thank you!