mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-06 14:54:42 +01:00
LCL, fix DbGrid with multiselect option will cause AV on application exit, issue #38303
git-svn-id: trunk@64378 -
This commit is contained in:
parent
adee13bfdd
commit
ad7d239447
@ -351,7 +351,6 @@ type
|
|||||||
FOldControlStyle: TControlStyle;
|
FOldControlStyle: TControlStyle;
|
||||||
FSelectedRows: TBookmarkList;
|
FSelectedRows: TBookmarkList;
|
||||||
FOnPrepareCanvas: TPrepareDbGridCanvasEvent;
|
FOnPrepareCanvas: TPrepareDbGridCanvasEvent;
|
||||||
FKeyBookmark: TBookmark;
|
|
||||||
FKeySign: Integer;
|
FKeySign: Integer;
|
||||||
FSavedRecord: Integer;
|
FSavedRecord: Integer;
|
||||||
FOnGetCellHint: TDbGridCellHintEvent;
|
FOnGetCellHint: TDbGridCellHintEvent;
|
||||||
@ -1317,10 +1316,6 @@ begin
|
|||||||
|
|
||||||
if MultiSel and not (dgMultiSelect in FOptions) then begin
|
if MultiSel and not (dgMultiSelect in FOptions) then begin
|
||||||
FSelectedRows.Clear;
|
FSelectedRows.Clear;
|
||||||
if FKeyBookmark<>nil then begin
|
|
||||||
FDatalink.DataSet.FreeBookmark(FKeyBookmark);
|
|
||||||
FKeyBookmark:=nil;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
EndLayout;
|
EndLayout;
|
||||||
@ -2037,10 +2032,6 @@ begin
|
|||||||
{$endif}
|
{$endif}
|
||||||
if not Value then begin
|
if not Value then begin
|
||||||
FSelectedRows.Clear;
|
FSelectedRows.Clear;
|
||||||
if FKeyBookmark<>nil then begin
|
|
||||||
FDatalink.DataSet.FreeBookmark(FKeyBookmark);
|
|
||||||
FKeyBookmark:=nil;
|
|
||||||
end;
|
|
||||||
RemoveAutomaticColumns;
|
RemoveAutomaticColumns;
|
||||||
end;
|
end;
|
||||||
LayoutChanged;
|
LayoutChanged;
|
||||||
@ -2352,6 +2343,7 @@ type
|
|||||||
TOperation=(opMoveBy,opCancel,opAppend,opInsert,opDelete);
|
TOperation=(opMoveBy,opCancel,opAppend,opInsert,opDelete);
|
||||||
var
|
var
|
||||||
DeltaCol,DeltaRow: Integer;
|
DeltaCol,DeltaRow: Integer;
|
||||||
|
preSelIndex, posSelIndex: Integer;
|
||||||
|
|
||||||
procedure DoOnKeyDown;
|
procedure DoOnKeyDown;
|
||||||
begin
|
begin
|
||||||
@ -2400,41 +2392,37 @@ var
|
|||||||
|
|
||||||
procedure SelectNext(const AStart,ADown:Boolean);
|
procedure SelectNext(const AStart,ADown:Boolean);
|
||||||
var
|
var
|
||||||
N: Integer;
|
N, curActiveRecord: Integer;
|
||||||
CurBookmark: TBookmark;
|
CurBookmark: TBookmark;
|
||||||
begin
|
begin
|
||||||
if dgPersistentMultiSelect in Options then
|
if dgPersistentMultiSelect in Options then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
if (ssShift in Shift) then begin
|
if (ssShift in Shift) then begin
|
||||||
|
if dgMultiSelect in Options then begin
|
||||||
CurBookmark := FDatalink.DataSet.GetBookmark;
|
curBookmark := FDatalink.DataSet.GetBookmark;
|
||||||
if FKeyBookmark=nil then
|
try
|
||||||
FKeyBookmark:=CurBookmark;
|
if AStart then preSelIndex := FSelectedRows.IndexOf(curBookmark)
|
||||||
|
else posSelIndex := FSelectedRows.IndexOf(curBookmark);
|
||||||
if (FKeyBookmark=CurBookmark) then begin
|
if not AStart then begin
|
||||||
if AStart then begin
|
FSelectedRows.CurrentRowSelected := true;
|
||||||
SelectRecord(true);
|
// deal with selection of previous (not prior) record
|
||||||
if ADown then
|
curActiveRecord := FDatalink.ActiveRecord;
|
||||||
FKeySign := 1
|
try
|
||||||
else
|
if ADown then FDatalink.ActiveRecord := FDatalink.ActiveRecord - 1
|
||||||
FKeySign := -1;
|
else FDatalink.ActiveRecord := FDatalink.ActiveRecord + 1;
|
||||||
exit;
|
if (preSelIndex>=0) and (posSelIndex>=0) then begin
|
||||||
|
if preSelIndex<>posSelIndex then
|
||||||
|
FSelectedRows.CurrentRowSelected := false
|
||||||
|
end else
|
||||||
|
FSelectedRows.CurrentRowSelected := true;
|
||||||
|
finally
|
||||||
|
FDatalink.ActiveRecord := curActiveRecord;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
FDatalink.DataSet.FreeBookmark(CurBookmark);
|
||||||
end;
|
end;
|
||||||
FKeySign := 0;
|
|
||||||
end else
|
|
||||||
FDatalink.DataSet.FreeBookmark(CurBookmark);
|
|
||||||
|
|
||||||
n := 4*Ord(FKeySign>=0) + 2*Ord(ADown) + 1*Ord(AStart);
|
|
||||||
case n of
|
|
||||||
0,6,8..11:
|
|
||||||
begin
|
|
||||||
SelectRecord(True);
|
|
||||||
end;
|
|
||||||
3,5:
|
|
||||||
begin
|
|
||||||
SelectRecord(False);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
ClearSelection(true);
|
ClearSelection(true);
|
||||||
@ -2785,10 +2773,6 @@ begin
|
|||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
|
||||||
if FKeyBookmark<>nil then begin
|
|
||||||
FDatalink.DataSet.FreeBookmark(FKeyBookmark);
|
|
||||||
FKeyBookmark:=nil; // force new keyboard selection start
|
|
||||||
end;
|
|
||||||
|
|
||||||
P:=MouseToCell(Point(X,Y));
|
P:=MouseToCell(Point(X,Y));
|
||||||
if Gz=gzFixedRows then
|
if Gz=gzFixedRows then
|
||||||
@ -3838,10 +3822,6 @@ begin
|
|||||||
if SelCurrent then
|
if SelCurrent then
|
||||||
SelectRecord(true);
|
SelectRecord(true);
|
||||||
end;
|
end;
|
||||||
if FKeyBookmark<>nil then begin
|
|
||||||
FDatalink.DataSet.FreeBookmark(FKeyBookmark);
|
|
||||||
FKeyBookmark:=nil;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomDBGrid.NeedAutoSizeColumns: boolean;
|
function TCustomDBGrid.NeedAutoSizeColumns: boolean;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user