Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004684 [JEDI VCL] 00 JVCL Components crash always 2009-01-30 19:17 2009-03-21 18:24
Reporter acastiello View Status public  
Assigned To AHUser
Priority normal Resolution fixed  
Status resolved   Product Version 3.35
Summary 0004684: TJvMemoryData fails to store and retrieve fields in Delphi 2009
Description Something 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 Information locate in unit JvMemoryDataset;
Tags No tags attached.
Attached Files ? file icon JvMemoryDataset.pas [^] (82,377 bytes) 2009-01-30 19:17

- Relationships

-  Notes
(0015275)
obones (administrator)
2009-02-02 00:26

It would seem much more logical to me to replace

Inc(Buffer)

by

Inc(Result)
(0015286)
acastiello (reporter)
2009-02-02 10:14

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
(0015323)
AHUser (developer)
2009-03-21 18:24

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


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker