From 57a394e4aed0a1ca91f8e38ad6cd9f6c7e461620 Mon Sep 17 00:00:00 2001 From: wp_xyz Date: Thu, 12 Dec 2024 11:58:38 +0100 Subject: [PATCH] TAChart: Fix crash when Hide is called for an inactive chart tool. (cherry picked from commit 72a834edbabc4ed6b0d53b87c1aa83ba71bcfdc9) --- components/tachart/tagraph.pas | 22 ++++++++++++++-------- components/tachart/tatools.pas | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/components/tachart/tagraph.pas b/components/tachart/tagraph.pas index 38ec6c39d0..ba2eb76acf 100644 --- a/components/tachart/tagraph.pas +++ b/components/tachart/tagraph.pas @@ -2183,18 +2183,24 @@ end; procedure TBasicChartTool.Activate; begin - FChart.FActiveToolIndex := Index; - FChart.MouseCapture := true; - FChart.FDisablePopupMenu := false; - FStartMousePos := Mouse.CursorPos; + if Assigned(FChart) then + begin + FChart.FActiveToolIndex := Index; + FChart.MouseCapture := true; + FChart.FDisablePopupMenu := false; + FStartMousePos := Mouse.CursorPos; + end; end; procedure TBasicChartTool.Deactivate; begin - FChart.MouseCapture := false; - FChart.FActiveToolIndex := -1; - if PopupMenuConflict then - FChart.FDisablePopupMenu := true; + if Assigned(FChart) then + begin + FChart.MouseCapture := false; + FChart.FActiveToolIndex := -1; + if PopupMenuConflict then + FChart.FDisablePopupMenu := true; + end; end; function TBasicChartTool.PopupMenuConflict: Boolean; diff --git a/components/tachart/tatools.pas b/components/tachart/tatools.pas index a0074eda08..6c533faff0 100644 --- a/components/tachart/tatools.pas +++ b/components/tachart/tatools.pas @@ -2202,7 +2202,7 @@ begin ADrawer.SetXor(false); end; tdmNormal: - FChart.StyleChanged(Self); + if Assigned(FChart) then FChart.StyleChanged(Self); end; end;