View Issue Details

IDProjectCategoryView StatusLast Update
0002188JEDI VCL00 JVCL Componentspublic2004-10-08 02:00
ReporteranonymousAssigned Touser72 
PrioritynormalSeverityblockReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.00 BETA 2 
Target VersionFixed in Version3.00 RC 1 
Summary0002188: JvDBImage issue
DescriptionDouble click or press <Enter> on JvDBImage.
Try to scroll on another record of database.
Exception: Dataset not in edit or insert state (even if JvDBImage is read-only).
Additional InformationSrc:

procedure TJvDBImage.UpdateData(Sender: TObject);
var
  Stream: TMemoryStream;
begin
  CheckFieldType;

  // If there is no graphic just clear field and exit
  if Picture.Graphic = nil then
  begin
    Field.Clear;
    Exit;
  end;

  Stream := TMemoryStream.Create;
  try
    Picture.Graphic.SaveToStream(Stream);
    Stream.Position := 0;
// Exception here:
    TBlobField(Field).LoadFromStream(Stream);
  finally
    Stream.Free;
  end;
end;
-----------------------------
Standard DBImage hasn't such bug (even if it is _not_ read-only).
TagsNo tags attached.

Activities

user72

2004-10-05 00:22

  ~0005305

Does the following work:

procedure TJvDBImage.UpdateData(Sender: TObject);
var
  Stream: TMemoryStream;
begin
  if ReadOnly then Exit; // add this line
  CheckFieldType;
...

anonymous

2004-10-06 02:26

viewer   ~0005323

>Does the following work:
> ...
> if ReadOnly then Exit; // add this line
> ...

Yes, it works but (as I said in my report):"Standard DBImage hasn't such bug (even if it is _not_ read-only)".

Why it works in standard DBImage? I don't know... Can anyboby give an answer?

user72

2004-10-06 07:11

  ~0005324

> Standard DBImage hasn't such bug (even if it is _not_ read-only).
Standard DBImage relies on the datalink field to do the right thing. Since we don't really know whether the images are the same (without reading a potentionally large stream from the database and compare it to the current image), the only option is to save the image every time.

If you don't want that, set ReadOnly to true and add the code in UpdateData as suggested.

anonymous

2004-10-06 23:11

viewer   ~0005330

Last edited: 2004-10-06 23:56

Here is a solution (compare it with borland TDBImage.LoadPicture).
-------------------------------
procedure TJvDBImage.LoadPicture;
begin
  // add this line
  if not FPictureLoaded then

   try
     Picture.Graphic := CreateGraphic;
   except
     Picture.Graphic := nil;
     raise;
   end;

end;

Now all work perfectly.
----------------------

Read-only is bad way.
1) If I want to modify a picture I must flip ReadOnly every time ...
2) It's not object oriented.
> Since we don't really know whether the images are the same
No. TPicture tracks out changes itself (remember OnChange event).
----------------------
Best regards,
Alex.

edited on: 10-06-04 23:56

user72

2004-10-07 05:31

  ~0005331

Ah, that explains it. I was certain that line was already in there but I never looked. OK, if that solves, I'll update it in CVS

user72

2004-10-08 02:00

  ~0005347

Updated in CVS. Thanks for the fix.

Issue History

Date Modified Username Field Change
2004-09-30 23:06 anonymous New Issue
2004-10-05 00:22 user72 Note Added: 0005305
2004-10-05 00:22 user72 Status new => feedback
2004-10-06 02:26 anonymous Note Added: 0005323
2004-10-06 07:11 user72 Note Added: 0005324
2004-10-06 23:11 anonymous Note Added: 0005330
2004-10-06 23:56 anonymous Note Edited: 0005330
2004-10-07 05:31 user72 Note Added: 0005331
2004-10-08 02:00 user72 Status feedback => resolved
2004-10-08 02:00 user72 Resolution open => fixed
2004-10-08 02:00 user72 Assigned To => user72
2004-10-08 02:00 user72 Note Added: 0005347