View Issue Details

IDProjectCategoryView StatusLast Update
0004684JEDI VCL00 JVCL Componentspublic2009-03-21 18:24
ReporteracastielloAssigned ToAHUser 
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.35 
Target VersionFixed in Version3.37 
Summary0004684: TJvMemoryData fails to store and retrieve fields in Delphi 2009
DescriptionSomething as simple as:
aJvMemoryData.FieldByName('fieldname').AsString := 'SomeValue';
fails
Add aJvMemoryData.FieldByName('fieldname').AsString to the watches and you will always get and empty string!
I traced the code and the problem seems to be in:
function TJvMemoryData.GetFieldData(Field: TField; Buffer: Pointer): Boolean;
function BufferLen(Buffer: {$IFDEF COMPILER12_UP}PByte{$ELSE}PChar{$ENDIF COMPILER12_UP}): Integer;

this is the old code:
  function BufferLen(Buffer: {$IFDEF COMPILER12_UP}PByte{$ELSE}PChar{$ENDIF COMPILER12_UP}): Integer;
  begin
    {$IFDEF COMPILER12_UP}
    Result := 0;
    if Buffer <> nil then
    begin
      while Buffer[Result] <> 0 do
        Inc(Buffer);
    end;
    {$ELSE}
    Result := StrLen(Buffer);
    {$ENDIF COMPILER12_UP}
  end;

this is my modified code:
  function BufferLen(Buffer: {$IFDEF COMPILER12_UP}PByte{$ELSE}PChar{$ENDIF COMPILER12_UP}): Integer;
  begin
    {$IFDEF COMPILER12_UP}
    Result := StrLen(PANSICHAR(Buffer));
    {$ELSE}
    Result := StrLen(Buffer);
    {$ENDIF COMPILER12_UP}
  end;
Additional Informationlocate in unit JvMemoryDataset;
TagsNo tags attached.

Activities

2009-01-30 19:17

 

JvMemoryDataset.pas (82,377 bytes)

obones

2009-02-02 00:26

administrator   ~0015275

It would seem much more logical to me to replace

Inc(Buffer)

by

Inc(Result)

acastiello

2009-02-02 10:14

reporter   ~0015286

Yes, that would do too, (I tested it :D). I made with Strlen to
a) Emphasize what BufferLen does
b) get shorter and clearer code
c) Not to code what is already coded :D

Regards,
Alvaro Castiello

AHUser

2009-03-21 18:24

developer   ~0015323

Fixed in SVN (rev. 12250)

Issue History

Date Modified Username Field Change
2009-01-30 19:17 acastiello New Issue
2009-01-30 19:17 acastiello File Added: JvMemoryDataset.pas
2009-02-02 00:26 obones Note Added: 0015275
2009-02-02 00:26 obones Status new => feedback
2009-02-02 10:14 acastiello Note Added: 0015286
2009-03-21 18:24 AHUser Note Added: 0015323
2009-03-21 18:24 AHUser Status feedback => resolved
2009-03-21 18:24 AHUser Fixed in Version => Daily / SVN
2009-03-21 18:24 AHUser Resolution open => fixed
2009-03-21 18:24 AHUser Assigned To => AHUser