Hi,
This may, or may not be related to
this thread, but I'm getting an external SIGFPE on my program when I do a
SQLQuery.Close; ID: string;
b: TStream;
begin
ID:=Form_DB.Datasource1.DataSet.FieldByName('ID').Value;
SQLQuery1.Close;
SQLQuery1.SQL.Text:='SELECT * FROM PREVIEWS WHERE ID='+ID;
SQLQuery1.Open;
if SQLQuery1.IsEmpty then
begin
getODDrawing(ID);
SQLQuery1.Close; //<--- SIGFPE Here
end;
end;
procedure TForm_DB.getODDrawing(ID: String);
var
BlkHandle: String;
R: TRect;
strm: Tstream;
begin
if BlobList=nil then BlobList:= TStringList.Create;//<---- BlobList is global TStringList
currentRecord:=ID;
SQLQuery1.Close;
SQLQuery1.SQL.Text:='SELECT PATHID,HANDLE FROM DWGMAP WHERE FIELDID='+ID;
SQLQuery1.Open;
ID:=SQLQuery1.FieldByName('PATHID').AsString;
BlkHandle:=SQLQuery1.FieldByName('HANDLE').AsString;
SQLQuery1.Close;
SQLQuery1.SQL.Text:='SELECT ACCESSED FROM PATHS WHERE ID='+ID;
SQLQuery1.Open;
ID:=SQLQuery1.FieldByName('ACCESSED').AsString;
SQLQuery1.Close;
SQLQuery1.SQL.Text:='SELECT ODDRAWING FROM USERSACCESS WHERE ID='+ID;
SQLQuery1.Open;
strm:=SQLQuery1.CreateBlobStream(SQLQuery1.Fields[0],bmRead);
BlobList.LoadFromStream(strm);
unit_display.showOD(BlkHandle);
R:=Rect(0,0,ImageWidth,ImageHeight);
Image1.Canvas.CopyRect(R,ImageBuffer.Canvas,R);
Screen.Cursor:=crDefault;
strm.Free;
end;
If it's the first record then it works fine. But if it's the second record (ie, another record has already been processed) then the SIGFPE occurs. Possible problem with the BlobList?
The SIGFPE opens an Assembler window which contains the following snippet:
5AD7258E 3bc7 cmp %edi,%eax
5AD72590 897df8 mov %edi,-0x8(%ebp)
5AD72593 7409 je 0x5ad7259e
5AD72595 844838 test %cl,0x38(%eax)
5AD72598 0f851bd60100 jne 0x5ad8fbb9 <UxTheme!GetThemeTextMetrics+8319>
5AD7259E 8b4508 mov 0x8(%ebp),%eax
5AD725A1 d9e8 fld1 <- Exception raised at 5AD725A1
The showOD() procedure steps through the blob list and draws on my ImageBuffer canvas. There is quite a lot of calculation done as each line in the BlobList contains a series of comma-separated points which must be split into Doubles and then scaled to fit and then truncated to integers before being rendered on the Imagebuffer canvas.
I realise that my coding is not all that elegant and my SQL is a little clunky, but any suggestions would be welcome.
~ Dave