diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2014-12-06 16:33:49 +0000 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2014-12-06 16:33:49 +0000 |
commit | 6c0709aee20e892cb14db00311f16c56ce25db67 (patch) | |
tree | 2435ee3b68e413d0fc54efb93dad1ff69a557905 /src/gui | |
parent | 61ff9bc373a3acad80ad68d1c78aeaca6950e243 (diff) | |
download | fpGUI-6c0709aee20e892cb14db00311f16c56ce25db67.tar.xz |
Fix ColMax() calculation.
When resizing the grid at runtime, the old implementation sometimes
called ColumnWidth[] with a -1 index causing an AV error.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/fpg_basegrid.pas | 16 |
1 files changed, 9 insertions, 7 deletions
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 |