Recent

Author Topic: [SOLVED]SIGSEVG in 'tatools.pas' at line 772;when creating a chart toolset dynam  (Read 2708 times)

CM630

  • Hero Member
  • *****
  • Posts: 1695
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
My code
Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var
  myChart: TChart;
  ctMain: TChartToolset;
  ctMainPanUD:  TPanDragTool;
begin
  myChart:=  TChart.Create (Form1);
  myChart.Visible:=True;
  myChart.Parent:= Form1;
  ctMain:= TChartToolset.Create (myChart);
  ctMainPanUD:= TPanDragTool.Create(ctMain);
  ctMainPanUD.Directions:=[pdUp,pdDown];
  ctMainPanUD.Shift:=[ssAlt,ssLeft];
  ctMainPanUD.Enabled:=True;
  ctMain.Tools.Add (ctMainPanUD);
  myChart.Toolset:=ctMain;
end;
 


crashes the app (sigsegv) with message
Quote
In file 'tatools.pas' at line 772;
Toolset.FIsHandled := true; 


The TATOOLS code is
Code: [Select]
procedure TChartTool.Handled;
begin
  Toolset.FIsHandled := true;
end;
   
When the chart, toolset  and tools are created statically everything is fine.
« Last Edit: February 05, 2014, 02:55:03 pm by paskal »
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

wp

  • Hero Member
  • *****
  • Posts: 13550
There had been similar discussions in the forum: Don't use TToolset.Add to add tools, but set the tool's property Toolset instead. The property setter calls the Add, plus sets the "Toolset" member of the new tool, and this avoids the crash:

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var
  myChart: TChart;
  ctMain: TChartToolset;
  ctMainPanUD:  TPanDragTool;
begin
  myChart:=  TChart.Create (Form1);
  myChart.Visible:=True;
  myChart.Parent:= Form1;
  ctMain:= TChartToolset.Create (myChart);
  ctMainPanUD:= TPanDragTool.Create(ctMain);
  ctMainPanUD.Directions:=[pdUp,pdDown];
  ctMainPanUD.Shift:=[ssAlt,ssLeft];
  ctMainPanUD.Enabled:=True;
  //ctMain.Tools.Add (ctMainPanUD);  // wrong
  ctMainPanUD.Toolset := ctMain;     // correct
  myChart.Toolset:=ctMain;
end;
« Last Edit: February 05, 2014, 02:15:46 pm by wp »

 

TinyPortal © 2005-2018