mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 23:59:10 +02:00
lcl: dbgrids: fixed TBookmark for fpc 2.7.1
git-svn-id: trunk@37092 -
This commit is contained in:
parent
537e40a7d9
commit
f43c7d764c
@ -3850,12 +3850,13 @@ end;
|
|||||||
|
|
||||||
procedure TBookmarkList.SetCurrentRowSelected(const AValue: boolean);
|
procedure TBookmarkList.SetCurrentRowSelected(const AValue: boolean);
|
||||||
var
|
var
|
||||||
Bookmark: TBookmark;
|
Bookmark: pointer;
|
||||||
Index: Integer;
|
Index: Integer;
|
||||||
begin
|
begin
|
||||||
CheckActive;
|
CheckActive;
|
||||||
|
|
||||||
Bookmark := FGrid.Datasource.Dataset.GetBookmark;
|
Bookmark := nil;
|
||||||
|
TBookmark(Bookmark) := FGrid.Datasource.Dataset.GetBookmark; // fetch and increase reference count
|
||||||
if Bookmark = nil then
|
if Bookmark = nil then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
@ -3863,14 +3864,22 @@ begin
|
|||||||
|
|
||||||
if Find(Bookmark, Index) then begin
|
if Find(Bookmark, Index) then begin
|
||||||
FDataset.FreeBookmark(Bookmark);
|
FDataset.FreeBookmark(Bookmark);
|
||||||
|
{$IFNDEF noautomatedbookmark}
|
||||||
|
SetLength(TBookmark(Bookmark),0); // decrease reference count
|
||||||
|
{$ENDIF noautomatedbookmark}
|
||||||
if not AValue then begin
|
if not AValue then begin
|
||||||
FDataset.FreeBookmark(Pointer(Items[Index]));
|
FDataset.FreeBookmark(Pointer(Items[Index]));
|
||||||
|
{$IFNDEF noautomatedbookmark}
|
||||||
|
SetLength(TBookmark(FList[Index]),0); // decrease reference count
|
||||||
|
{$ENDIF noautomatedbookmark}
|
||||||
FList.Delete(Index);
|
FList.Delete(Index);
|
||||||
FGrid.Invalidate;
|
FGrid.Invalidate;
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
if AValue then begin
|
if AValue then begin
|
||||||
FList.Insert(Index, Pointer(Bookmark));
|
// the reference count of Bookmark was increased above, so it is save to
|
||||||
|
// store it here as pointer
|
||||||
|
FList.Insert(Index, Bookmark);
|
||||||
FGrid.Invalidate;
|
FGrid.Invalidate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -3901,7 +3910,12 @@ var
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
for i:=0 to FList.Count-1 do
|
for i:=0 to FList.Count-1 do
|
||||||
|
begin
|
||||||
FDataset.FreeBookmark(Items[i]);
|
FDataset.FreeBookmark(Items[i]);
|
||||||
|
{$IFNDEF noautomatedbookmark}
|
||||||
|
SetLength(TBookmark(FList[i]),0); // decrease reference count
|
||||||
|
{$ENDIF noautomatedbookmark}
|
||||||
|
end;
|
||||||
FList.Clear;
|
FList.Clear;
|
||||||
FGrid.Invalidate;
|
FGrid.Invalidate;
|
||||||
end;
|
end;
|
||||||
@ -3913,6 +3927,9 @@ begin
|
|||||||
for i := 0 to FList.Count - 1 do begin
|
for i := 0 to FList.Count - 1 do begin
|
||||||
FDataset.GotoBookmark(Items[i]);
|
FDataset.GotoBookmark(Items[i]);
|
||||||
FDataset.Delete;
|
FDataset.Delete;
|
||||||
|
{$IFNDEF noautomatedbookmark}
|
||||||
|
SetLength(TBookmark(FList[i]),0); // decrease reference count
|
||||||
|
{$ENDIF noautomatedbookmark}
|
||||||
FList.Delete(i);
|
FList.Delete(i);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -3921,11 +3938,10 @@ type
|
|||||||
TDs=class(TDataset)
|
TDs=class(TDataset)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function MyCompareBookmarks(ds:Tdataset; b1,b2:TBookmark): Integer;
|
function MyCompareBookmarks(ds:Tdataset; b1,b2:pointer): Integer;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
{$IFDEF noautomatedbookmark}
|
|
||||||
if b1=b2 then
|
if b1=b2 then
|
||||||
result := 0
|
result := 0
|
||||||
else
|
else
|
||||||
@ -3935,20 +3951,9 @@ begin
|
|||||||
if b2=nil then
|
if b2=nil then
|
||||||
result := 1
|
result := 1
|
||||||
else begin
|
else begin
|
||||||
|
// Note: Tds(ds).bookmarksize is set at creation of TDataSet and does not change
|
||||||
result := CompareMemRange(b1,b2,Tds(ds).bookmarksize);
|
result := CompareMemRange(b1,b2,Tds(ds).bookmarksize);
|
||||||
end;
|
end;
|
||||||
{$ELSE}
|
|
||||||
if b1=b2 then
|
|
||||||
exit(0)
|
|
||||||
else if length(b1)<length(b2) then
|
|
||||||
exit(-1)
|
|
||||||
else if length(b1)>length(b2) then
|
|
||||||
exit(1)
|
|
||||||
else if length(b1)=0 then
|
|
||||||
exit(0)
|
|
||||||
else
|
|
||||||
result:=CompareMemRange(@b1[0],@b2[0],length(b1));
|
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBookmarkList.Find(const Item: TBookmark; var AIndex: Integer): boolean;
|
function TBookmarkList.Find(const Item: TBookmark; var AIndex: Integer): boolean;
|
||||||
@ -3963,7 +3968,7 @@ begin
|
|||||||
while (L <= R) do
|
while (L <= R) do
|
||||||
begin
|
begin
|
||||||
I := L + (R - L) div 2;
|
I := L + (R - L) div 2;
|
||||||
CompareRes := MyCompareBookmarks(FDataset, Item, TBookmark(FList[I]));
|
CompareRes := MyCompareBookmarks(FDataset, pointer(Item), FList[I]);
|
||||||
//CompareRes := FDataset.CompareBookmarks(Item, TBookmark(FList[I]));
|
//CompareRes := FDataset.CompareBookmarks(Item, TBookmark(FList[I]));
|
||||||
if (CompareRes > 0) then
|
if (CompareRes > 0) then
|
||||||
L := I + 1
|
L := I + 1
|
||||||
|
Loading…
Reference in New Issue
Block a user