From d660825c51ca5fbd17a56b2df1d101c334b38f06 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 3 Nov 2020 10:45:14 +0000 Subject: [PATCH] LazStats: Fix SRHTestUnit crashing at CloseFile. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7839 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../analysis/nonparametric/srhtestunit.pas | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/applications/lazstats/source/forms/analysis/nonparametric/srhtestunit.pas b/applications/lazstats/source/forms/analysis/nonparametric/srhtestunit.pas index 2a321eba8..5c1966ab6 100644 --- a/applications/lazstats/source/forms/analysis/nonparametric/srhtestunit.pas +++ b/applications/lazstats/source/forms/analysis/nonparametric/srhtestunit.pas @@ -73,6 +73,8 @@ type F1Labels: StrDyneVec; F2Labels: StrDyneVec; + procedure GetColsSelected(out AColsSelected: IntDyneVec); + function GetLabels(AColsSelected: IntDyneVec): Boolean; function Calc2Way(const AColsSelected: IntDyneVec; @@ -364,10 +366,7 @@ var res: TSRHResults; begin // Get column numbers of dependent variable and factors - SetLength(colNoSelected, 3); - colNoSelected[0] := GetVariableIndex(OS3MainFrm.DataGrid, DepVar.Text); - colNoSelected[1] := GetVariableIndex(OS3MainFrm.DataGrid, Factor1.Text); - colNoSelected[2] := GetVariableIndex(OS3MainFrm.DataGrid, Factor2.Text); + GetColsSelected(colNoSelected); // get labels for each factor level if not GetLabels(colNoSelected) then @@ -461,6 +460,16 @@ begin end; +procedure TSRHTestForm.GetColsSelected(out AColsSelected: IntDyneVec); +begin + AColsSelected := nil; + SetLength(AColsSelected, 3); + AColsSelected[0] := GetVariableIndex(OS3MainFrm.DataGrid, DepVar.Text); + AColsSelected[1] := GetVariableIndex(OS3MainFrm.DataGrid, Factor1.Text); + AColsSelected[2] := GetVariableIndex(OS3MainFrm.DataGrid, Factor2.Text); +end; + + function TSRHTestForm.GetLabels(AColsSelected: IntDyneVec): Boolean; var i, nF1, nF2: integer; @@ -758,8 +767,11 @@ var begin tb := Sender as TToolButton; tb.Down := true; - FChartSeries.Source := FChartSources[tb.Tag - 10]; + if FChartSeries = nil then + exit; + + FChartSeries.Source := FChartSources[tb.Tag - 10]; case tb.Tag-10 of 0: begin // x = Factor 1 FChartFrame.SetTitle(Factor1.Text); @@ -798,13 +810,15 @@ procedure TSRHTestForm.Reset; var i : integer; begin + FreeAndNil(FChartSeries); + inherited; if FChartSources[0] <> nil then begin + //SelectPlot(FSeriesButtons[0]); for i := 0 to High(FChartSources) do FChartSources[i].Clear; - SelectPlot(FSeriesButtons[0]); end; DepVar.Clear;