From 00ac786d09deab8f92d007dfb9de372c2d5d3722 Mon Sep 17 00:00:00 2001 From: bart <9132501-flyingsheep@users.noreply.gitlab.com> Date: Sat, 5 Oct 2013 20:30:04 +0000 Subject: [PATCH] ValEdit: Fix crash in InsertRow if Strings.Count = 0. Issue #0025144. git-svn-id: trunk@43109 - --- lcl/valedit.pas | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lcl/valedit.pas b/lcl/valedit.pas index 61ace5bebe..2a2ef99404 100644 --- a/lcl/valedit.pas +++ b/lcl/valedit.pas @@ -819,7 +819,12 @@ begin Strings.BeginUpdate; try if Append then - NewInd := Row - FixedRows + 1 //append after current row + begin + if (Strings.Count = 0) then //empty grid + NewInd := 0 + else + NewInd := Row - FixedRows + 1 //append after current row + end else NewInd := Row - FixedRows; //insert it at current row Strings.InsertItem(NewInd, Line, Nil);