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
0004285 [JEDI VCL] 00 JVCL Components crash always 2007-10-31 12:54 2007-12-16 12:58
Reporter locopablo View Status public  
Assigned To AHUser
Priority normal Resolution fixed  
Status resolved   Product Version 3.32
Summary 0004285: TJvMemoryData causes access violation when assigning a WideString value to a TWideStringField
Description Assigning a value to a WideString field causes an access violation.

Sample code:

memds := TJvMemoryData.Create(nil);
try
  memds.FieldDefs.Add('ss', ftString, 20, False);
  memds.FieldDefs.Add('ws', ftWideString, 20, False);
  memds.Active := True;
  memds.Append;
  memds.Fields[0].Value := 'abc123';
// next line causes A/V
  memds.Fields[1].Value := 'abc123';
  memds.Post;
finally
  FreeAndNil(memds);
end;


Additional Information Failure seems to be caused by this function:

procedure TJvMemoryData.DataConvert(Field: TField; Source, Dest: Pointer; ToNative: Boolean);
begin
  if Field.DataType = ftWideString then
  begin
    // copied from DB.PAS - this works OK
    WStrCopy(PWideChar(Dest), PWideChar(Source));
    { // Original code - crashes with A/V
    if ToNative then
    begin
      Word(Dest^) := Length(PWideString(Source)^) * 2;
      Move(PWideChar(Source^)^, (PWideChar(Dest) + 1)^, Word(Dest^));
    end
    else
      SetString(WideString(Dest^), PWideChar(PChar(Source) + 2), Word(Source^) div 2);
    }
  end
  else
    inherited DataConvert(Field, Source, Dest, ToNative);
end;

Tags No tags attached.
Attached Files

- Relationships
has duplicate 0004412resolvedAHUser unit jvMemoryDataset 

-  Notes
(0014024)
locopablo (reporter)
2007-11-07 08:27

It seems the internal data handling has changed quite a bit between versions and the code above does not make BDS2006 very happy... BDS 2006 includes its own internal storage of WideString data, which uses the WStrCopy() function.

Adding an ifdef to the DataConvert function makes WideString value assignemt work for both BDS2006 and Delphi 5.

interface

...TJvMemoryData...
{$IFNDEF DELPHI10_UP}
  procedure DataConvert(Field: TField; Source, Dest: Pointer; ToNative: Boolean);
end;
{$ENDIF}

implementation

{$IFNDEF DELPHI10_UP}
procedure TJvMemoryData.DataConvert(Field: TField; Source, Dest: Pointer; ToNative: Boolean);
begin
...
end;
{$ENDIF}
(0014067)
AHUser (developer)
2007-12-16 12:58

Fixed in SVN.

- Issue History
Date Modified Username Field Change
2007-10-31 12:54 locopablo New Issue
2007-11-07 08:27 locopablo Note Added: 0014024
2007-12-16 12:58 AHUser Status new => resolved
2007-12-16 12:58 AHUser Fixed in Version => Daily / SVN
2007-12-16 12:58 AHUser Resolution open => fixed
2007-12-16 12:58 AHUser Assigned To => AHUser
2007-12-16 12:58 AHUser Note Added: 0014067
2008-11-02 12:34 AHUser Relationship added has duplicate 0004412


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