View Issue Details

IDProjectCategoryView StatusLast Update
0012030LazarusDatabasepublic2011-12-01 10:22
ReporterOsvaldo TCF Assigned ToVincent Snijders  
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionunable to reproduce 
Product Version0.9.25 (SVN) 
Summary0012030: TDBImage AV
DescriptionWhen i link tdbimage with my dataset and the property autodisplay is true, i get an access violation when dataset is open
Additional Informationsvn
ubuntu 8.04.1
fpc 2.2.3
DB: Firebird 2.0.4
Field: Blobfield
Components> UIB-FBDataset or SQLQuery + IBConection

Perhaps the problems is in loadpicture procedure.
TagsNo tags attached.
Fixed in Revision
LazTarget1.2
WidgetsetGTK 2
Attached Files

Relationships

parent of 0014698 closedMarc Weustink Patches Picture can not be loaded from raw stream (unknown format) 

Activities

Osvaldo TCF

2008-09-02 22:15

reporter   ~0021940

With my image: a .jpg file
---------------------------
in dbimage.inc, line 163:
        try
          GraphExt := s.ReadAnsiString;

          gc := GetGraphicClassForFileExtension(GraphExt);
          if assigned(gc) then
            begin
            AGraphic := gc.Create;
            AGraphic.LoadFromStream(s);

            Picture.Assign(AGraphic);
            end;
-------------------------------------------

gc is not assigned, is it correct?

Luiz Americo

2008-09-03 02:04

developer   ~0021941

Try to change Picture.Assign(AGraphic); to Picture.Graphic := AGraphic;

Osvaldo TCF

2008-09-03 17:42

reporter   ~0021965

Nop,
the problem is in s.readstring, the program flow do not go in this part.

Osvaldo TCF

2008-09-03 17:44

reporter   ~0021966

This well for Jpeg images:
===============================================================
//dbimage.inc line 135

procedure TDBImage.LoadPicture;
var //s : TMemory; // ( lazarus team)
    s : TMemoryStream; // ( mine )
    GraphExt : string;
    gc : TGraphicClass;
    AGraphic : TGraphic;

begin
  if not FPictureLoaded then
    begin
    FUpdatingRecord := True;
    if not assigned(FDatalink.Field) then Picture.Assign(FDatalink.Field)
    else
    if FDatalink.field.IsBlob then
      begin
      if FDatalink.field is TBlobField then
        begin
        if FDatalink.Field.IsNull then
          begin
          Picture.Clear;
          exit;
          end;
    //FDataLink.DataSet.CreateBlobStream(FDataLink.Field,bmRead); // (lazarus team)

    s := TMemoryStream.create; // ( mine )
        (FDataLink.Field as TBlobField).SaveToStream(s); // ( mine )
        s.Position:= 0; // ( mine )

        if (S=Nil) or (s.Size = 0) then
          begin
          Picture.Clear;
          exit;
          end;
        try
          //GraphExt := s.ReadAnsiString; // (lazarus team)
          // gc := GetGraphicClassForFileExtension(GraphExt); // (lazarus team)
          // if assigned(gc) then // (lazarus team)
          // begin // (lazarus team)
          
      Picture.Jpeg.LoadFromStream(s); // ( mine )
      
      //AGraphic. := gc.Create; // (lazarus team)
      //AGraphic.LoadFromStream(s); // (lazarus team)
      //Picture.Assign(AGraphic);
            //end;
        finally
          //if assigned(AGraphic) then AGraphic.Free; // (lazarus team)
          s.Free;
        end {try}

        end
      else
        Picture.Assign(FDataLink.FField);
      end;
    FUpdatingRecord := False;
    end;
end;

===============================================================

Osvaldo TCF

2008-09-04 19:28

reporter   ~0021997

Last edited: 2008-09-05 15:43

now the problem is when load a new file for the picture.
Perhaps a problem with stream;
when i use loadfromfile a have problem, when i use loadfromstream this ok.

But the loadfromstream use a TMemoryStream. Like this:

st := TMemorystream.create;
dbimage1.picture.loadfromstream(st)

Anyone can test?

Boguslaw Brandys

2009-04-21 22:27

developer   ~0026914

IMHO We need small example project showing that error

Jesus Reyes

2009-10-08 17:08

developer   ~0031204

please show how you updated the data in the blob field. TDbImage expects the blob data in a special format, it should be ok if you use dbimage1.Picture.LoadFromFile('file-in-any-supported-format');

Vincent Snijders

2009-12-11 12:30

manager   ~0032952

No feedback from reporter.

Issue History

Date Modified Username Field Change
2008-09-01 18:08 Osvaldo TCF New Issue
2008-09-01 18:08 Osvaldo TCF Widgetset => GTK 2
2008-09-01 19:16 Vincent Snijders LazTarget => 1.2
2008-09-01 19:16 Vincent Snijders Status new => acknowledged
2008-09-02 22:15 Osvaldo TCF Note Added: 0021940
2008-09-03 02:04 Luiz Americo Note Added: 0021941
2008-09-03 17:42 Osvaldo TCF Note Added: 0021965
2008-09-03 17:44 Osvaldo TCF Note Added: 0021966
2008-09-04 19:28 Osvaldo TCF Note Added: 0021997
2008-09-05 15:43 Osvaldo TCF Note Edited: 0021997
2009-04-21 22:27 Boguslaw Brandys Note Added: 0026914
2009-10-01 07:49 Vincent Snijders Relationship added parent of 0014698
2009-10-08 17:08 Jesus Reyes Note Added: 0031204
2009-10-08 17:08 Jesus Reyes Status acknowledged => feedback
2009-12-11 12:30 Vincent Snijders Status feedback => resolved
2009-12-11 12:30 Vincent Snijders Resolution open => unable to reproduce
2009-12-11 12:30 Vincent Snijders Assigned To => Vincent Snijders
2009-12-11 12:30 Vincent Snijders Note Added: 0032952
2011-12-01 10:22 Marc Weustink Status resolved => closed