TStringGrid copy selection bug, when cell in last column in selected range is empty.
Original Reporter info from Mantis: K155LA3
-
Reporter name:
Original Reporter info from Mantis: K155LA3
- Reporter name:
Description:
If you copy multiple cells and the last will be empty, when you paste the copied range, the last empty cell is not inserted.
This bug is present in version 1.7(SVN).
Steps to reproduce:
1 Place StringGrid to form.
2 Set in Options goEditing
3 Run programm
4 Fill some cell with any data.
5 Select some empty cell an press Ctrl+C
6 Place cursor on first cell with data and press Ctrl+V
7 All except the last cell will be replaced.
Additional information:
This problem located in sub procedure "CollectCols" in procedure "TCustomStringGrid.SelectionSetText":
begin
Subl.Clear;
P := Pchar(S);
if P<>nil then
while P^<>#0 do begin
ini := P;
while (P^<>#0) and (P^<>#9) do
Inc(P);
if P=Ini then
St := ''
else begin
SetLength(St, P-Ini);
Move(Ini^,St[1],P-Ini);
end;
SubL.Add(St);
if P^<>#0 then
Inc(P);
end;
end;
If last cell was empty, than after checks "if P^<>#0 then Inc(P);" P^ will is #0 and cycle was end.
To eliminate such a need to introduce additional checks:
begin
Subl.Clear;
P := Pchar(S);
if P<>nil then
while P^<>#0 do begin
ini := P;
while (P^<>#0) and (P^<>#9) do
Inc(P);
if P=Ini then
St := ''
else begin
SetLength(St, P-Ini);
Move(Ini^,St[1],P-Ini);
end;
SubL.Add(St);
if P^<>#0 then
begin
Inc(P);
if P^ = #0 then SubL.Add(''); //additional checks
end;
end;
end;
Mantis conversion info:
- Mantis ID: 30454
- OS: Windows
- OS Build: 7
- Version: 1.6
- Fixed in version: 1.7 (SVN)
- Fixed in revision: 52904 (#ca41291b)
- Target version: 1.8