From 115a423be588f0073443a55282af49e291748726 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 2 Jun 2018 16:35:14 +0000 Subject: [PATCH] fpspreadsheet: Fix crash when a row is deleted with a formula and referenced cells of another formula (see discussion in https://forum.lazarus.freepascal.org/index.php/topic,41161.msg287707.html#msg287707). git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6452 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/source/common/fpsclasses.pas | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/components/fpspreadsheet/source/common/fpsclasses.pas b/components/fpspreadsheet/source/common/fpsclasses.pas index d4a06ac74..da11492c6 100644 --- a/components/fpspreadsheet/source/common/fpsclasses.pas +++ b/components/fpspreadsheet/source/common/fpsclasses.pas @@ -1453,11 +1453,12 @@ begin // Remove and destroy the formula record if it is in the deleted row if formula^.Row = AIndex then Delete(node) - else - if formula^.Row > AIndex then - dec(formula^.Row); - // Update all RowCol records at row indexes above the deleted row - changed := formula^.Parser.IterateNodes(@FixDeletedRow, Pointer(PtrInt(AIndex))); + else begin + if formula^.Row > AIndex then + dec(formula^.Row); + // Update all RowCol records at row indexes above the deleted row + changed := formula^.Parser.IterateNodes(@FixDeletedRow, Pointer(PtrInt(AIndex))); + end; end else begin // Remove and destroy the formula record if it is in the deleted column