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
0002188 [JEDI VCL] 00 JVCL Components block always 2004-09-30 23:06 2004-10-08 02:00
Reporter anonymous View Status public  
Assigned To user72
Priority normal Resolution fixed  
Status resolved   Product Version 3.00 BETA 2
Summary 0002188: JvDBImage issue
Description Double 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 Information Src:

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).
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0005305)
user72
2004-10-05 00:22

Does the following work:

procedure TJvDBImage.UpdateData(Sender: TObject);
var
  Stream: TMemoryStream;
begin
  if ReadOnly then Exit; // add this line
  CheckFieldType;
...
(0005323)
anonymous (viewer)
2004-10-06 02:26

>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?
(0005324)
user72
2004-10-06 07:11

> 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.
(0005330)
anonymous (viewer)
2004-10-06 23:11
edited on: 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
(0005331)
user72
2004-10-07 05:31

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
(0005347)
user72
2004-10-08 02:00

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


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