Browse Source

* Fix never-ending loop when setting filter

michael 5 years ago
parent
commit
816d7bd3e1
1 changed files with 7 additions and 1 deletions
  1. 7 1
      packages/fcl-db/jsondataset.pas

+ 7 - 1
packages/fcl-db/jsondataset.pas

@@ -1333,7 +1333,7 @@ begin
         else
         else
           Result := grBOF; // begin of file
           Result := grBOF; // begin of file
       gmCurrent: // check if empty
       gmCurrent: // check if empty
-        if fCurrent >= fCurrentIndex.Count then
+        if (FCurrent<0) or (fCurrent >= fCurrentIndex.Count) then
           Result := grEOF;
           Result := grEOF;
     end;
     end;
     if Result = grOK then // read the data
     if Result = grOK then // read the data
@@ -1347,6 +1347,12 @@ begin
         begin
         begin
         FFilterRow:=Buffer.Data;
         FFilterRow:=Buffer.Data;
         recordAccepted:=DoFilterRecord;
         recordAccepted:=DoFilterRecord;
+        if Not RecordAccepted and (GetMode=gmCurrent) then
+          begin
+          // Transform to EOF.
+          RecordAccepted:=True;
+          Result:=grEOF;
+          end;
         end;
         end;
       end;
       end;
   until recordAccepted;
   until recordAccepted;