瀏覽代碼

* Fixed accessing TCustomBufDataset.IndexName and CompareBookmarks from a new instance (bug 16695+adapted test)

git-svn-id: trunk@15412 -
joost 15 年之前
父節點
當前提交
fb3ede2ef7
共有 2 個文件被更改,包括 7 次插入2 次删除
  1. 5 2
      packages/fcl-db/src/base/bufdataset.pas
  2. 2 0
      packages/fcl-db/tests/testdbbasics.pas

+ 5 - 2
packages/fcl-db/src/base/bufdataset.pas

@@ -2206,7 +2206,10 @@ end;
 
 function TCustomBufDataset.GetIndexName: String;
 begin
-  result := FCurrentIndex.Name;
+  if FIndexesCount>0 then
+    result := FCurrentIndex.Name
+  else
+    result := '';
 end;
 
 function TCustomBufDataset.GetBufUniDirectional: boolean;
@@ -2633,7 +2636,7 @@ end;
 function TCustomBufDataset.CompareBookmarks(Bookmark1, Bookmark2: TBookmark
   ): Longint;
 begin
-  if FCurrentIndex.CompareBookmarks(Bookmark1,Bookmark2) then
+  if Assigned(FCurrentIndex) and FCurrentIndex.CompareBookmarks(Bookmark1,Bookmark2) then
     Result := 0
   else
     Result := -1;

+ 2 - 0
packages/fcl-db/tests/testdbbasics.pas

@@ -543,6 +543,8 @@ var s : string;
 begin
   bufds := DBConnector.GetNDataset(5) as TCustomBufDataset;
   s := bufds.IndexFieldNames;
+  s := bufds.IndexName;
+  bufds.CompareBookmarks(nil,nil);
 end;
 
 procedure TTestDBBasics.TestCanModifySpecialFields;