I have a TDBImage control on my form.
Users can CTRL-V images in to it. They can also CTRL-X in the control to clear the image.
When I later try to take the contents of that TDBImage as save it to my database I get memory access violations, in particular when I generate the memory stream.
Naturally my first inclination is to see if the TDBImage is somehow empty before I do this (and clear the database field my self). But I can't seem to find a way to detect if the control has been CTRL-X'ed by the user.
Here's a very condensed version of what my existing code looks like if it helps.
var
photo: TDBImage;
photoValue: TPicture;
photoStream: TMemoryStream;
updateQuery: TOraQuery;
begin
// ....
// It gets through here without complaint
photoValue := photo.Picture;
// It fails on this line
photoValue.Graphic.SaveToStream(photoStream);
updateQuery.paramByName('picture').ParamType := ptInput;
updateQuery.paramByName('picture').AsOraBlob.LoadFromStream(photoStream);
updateQuery.ExecSQL;
// ...
end;
How can I detect an empty/CTRL-Xed TDBImage control?