From 6c0709aee20e892cb14db00311f16c56ce25db67 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Sat, 6 Dec 2014 16:33:49 +0000 Subject: Fix ColMax() calculation. When resizing the grid at runtime, the old implementation sometimes called ColumnWidth[] with a -1 index causing an AV error. --- src/gui/fpg_basegrid.pas | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/gui') diff --git a/src/gui/fpg_basegrid.pas b/src/gui/fpg_basegrid.pas index 5ed95ab4..2df7b414 100644 --- a/src/gui/fpg_basegrid.pas +++ b/src/gui/fpg_basegrid.pas @@ -738,16 +738,18 @@ var function ColMax: integer; var - i : integer; + i: integer; + w: integer; begin - i := 0; - result := ColumnCount; - while i < HWidth do + w := 0; + Result := 0; + for i := 0 to ColumnCount-1 do begin - dec(result); - i := i + ColumnWidth[result]; + w := w + ColumnWidth[i]; + if w > Width then + inc(Result); end; - inc(result); + inc(Result); end; begin -- cgit v1.2.3-70-g09d2