View Issue Details

IDProjectCategoryView StatusLast Update
0028743LazarusLCLpublic2016-07-18 03:21
ReporterLuiz AmericoAssigned ToJesus Reyes 
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product VersionProduct Build 
Target Version1.8Fixed in Version1.7 (SVN) 
Summary0028743: Fix result of DBGrid.MyCompareBookmarks
DescriptionAccording to tests in various Delphi TDataset implementations CompareBookmarks should return 1 when nil is the first argument.

The attached patch that swaps the result when one of the arguments is nil.

In practice there should be no difference (it does not affect the search result and no nil value can reach this code).

I tested with TDbf and TSqlite3Dataset that implements the new behavior for CompareBookmarks and no problem at all.

See http://bugs.freepascal.org/view.php?id=28730 for more info
TagsNo tags attached.
Fixed in Revision52706
LazTarget1.8
Widgetset
Attached Files
  • fixdbgrid-mycomparebookmarks.diff (442 bytes)
    diff --git lcl/dbgrids.pas lcl/dbgrids.pas
    index 498a99e..d7ed91e 100644
    --- lcl/dbgrids.pas
    +++ lcl/dbgrids.pas
    @@ -4455,10 +4455,10 @@ begin
         result := 0
       else
       if b1=nil then
    -    result := 1
    +    result := -1
       else
       if b2=nil then
    -    result := -1
    +    result := 1
       else begin
         // Note: Tds(ds).bookmarksize is set at creation of TDataSet and does not change
         result := CompareMemRange(b1,b2,Tds(ds).bookmarksize);
    
  • fixdbgrid-mycomparebookmarks-correct.diff (442 bytes)
    diff --git lcl/dbgrids.pas lcl/dbgrids.pas
    index d7ed91e..498a99e 100644
    --- lcl/dbgrids.pas
    +++ lcl/dbgrids.pas
    @@ -4455,10 +4455,10 @@ begin
         result := 0
       else
       if b1=nil then
    -    result := -1
    +    result := 1
       else
       if b2=nil then
    -    result := 1
    +    result := -1
       else begin
         // Note: Tds(ds).bookmarksize is set at creation of TDataSet and does not change
         result := CompareMemRange(b1,b2,Tds(ds).bookmarksize);
    

Activities

Luiz Americo

2015-09-28 22:45

developer  

fixdbgrid-mycomparebookmarks.diff (442 bytes)
diff --git lcl/dbgrids.pas lcl/dbgrids.pas
index 498a99e..d7ed91e 100644
--- lcl/dbgrids.pas
+++ lcl/dbgrids.pas
@@ -4455,10 +4455,10 @@ begin
     result := 0
   else
   if b1=nil then
-    result := 1
+    result := -1
   else
   if b2=nil then
-    result := -1
+    result := 1
   else begin
     // Note: Tds(ds).bookmarksize is set at creation of TDataSet and does not change
     result := CompareMemRange(b1,b2,Tds(ds).bookmarksize);

Jesus Reyes

2015-09-29 20:24

developer   ~0086166

Strange, it looks as if your copy is reversed. The requested change is actually the current one in trunk and 1.4.2

LacaK

2015-09-30 08:25

developer   ~0086175

Correct should be:

  if b1=b2 then
    result := 0
  else
  if b1=nil then
    result := 1
  else
  if b2=nil then
    result := -1
  else begin

Not logical, but Delphi compatible ;-(

Luiz Americo

2015-10-02 02:14

developer  

fixdbgrid-mycomparebookmarks-correct.diff (442 bytes)
diff --git lcl/dbgrids.pas lcl/dbgrids.pas
index d7ed91e..498a99e 100644
--- lcl/dbgrids.pas
+++ lcl/dbgrids.pas
@@ -4455,10 +4455,10 @@ begin
     result := 0
   else
   if b1=nil then
-    result := -1
+    result := 1
   else
   if b2=nil then
-    result := 1
+    result := -1
   else begin
     // Note: Tds(ds).bookmarksize is set at creation of TDataSet and does not change
     result := CompareMemRange(b1,b2,Tds(ds).bookmarksize);

Luiz Americo

2015-10-02 02:15

developer   ~0086204

Attached the correct patch. Sorry for the confusion

Jesus Reyes

2016-07-17 21:31

developer   ~0093745

Applied, thanks.

Luiz Americo

2016-07-18 03:20

developer   ~0093749

Thanks

Issue History

Date Modified Username Field Change
2015-09-28 22:45 Luiz Americo New Issue
2015-09-28 22:45 Luiz Americo File Added: fixdbgrid-mycomparebookmarks.diff
2015-09-29 19:40 Jesus Reyes Assigned To => Jesus Reyes
2015-09-29 19:40 Jesus Reyes Status new => assigned
2015-09-29 20:24 Jesus Reyes Note Added: 0086166
2015-09-29 20:24 Jesus Reyes Status assigned => feedback
2015-09-30 08:25 LacaK Note Added: 0086175
2015-10-02 02:14 Luiz Americo File Added: fixdbgrid-mycomparebookmarks-correct.diff
2015-10-02 02:15 Luiz Americo Note Added: 0086204
2015-10-02 02:15 Luiz Americo Status feedback => assigned
2016-07-17 21:31 Jesus Reyes Fixed in Revision => 52706
2016-07-17 21:31 Jesus Reyes LazTarget - => 1.8
2016-07-17 21:31 Jesus Reyes Note Added: 0093745
2016-07-17 21:31 Jesus Reyes Status assigned => resolved
2016-07-17 21:31 Jesus Reyes Fixed in Version => 1.7 (SVN)
2016-07-17 21:31 Jesus Reyes Resolution open => fixed
2016-07-17 21:31 Jesus Reyes Target Version => 1.8
2016-07-18 03:20 Luiz Americo Note Added: 0093749
2016-07-18 03:21 Luiz Americo Status resolved => closed