Strange Crash following ent_extent call (D4D)
Posted: Mon Jun 24, 2019 2:58 pm
I am experiencing a problem where a call to Ent_Extent is causing a crash in subsequent logic. This is not causing me an immediate issue as I have implemented alternative logic that does not crash (in fact my new logic is probably more efficient as it utilises extents that have already been calculated), but just wondering if anybody can provide any insight as to why ent_extent might be causing the crash described below ...
I have a procedure that calls several other procedures (some of which are nested within my procedure ... one of the nested procedures is called repeatedly and uses ent_extent without any problems). The section of code below occurs toward the end of my procedure.
- If I comment out the ent_extent call on line 25 then there is no crash (as expected the subsequent drag box does not display correctly but otherwise no problems).
- if I leave the ent_extent call in the code then it returns correct values for botleft and topright, and the code continues to process correctly until the end of the procedure is reached. At the end of the procedure DataCAD becomes unresponsive (for several seconds on my rather slow laptop) and then crashes (the whole program exits, not just the current drawing).
Don't know if the issue might be a bug with the ent_extent call (it is used is many other places in the macro without any issues), or even a bug with Delphi itself. Both seem unlikely, but I can't see any issues with my code.
Perhaps somebody else may be able to spot an issue or at least throw some light on a possible cause of the crash.
Thanks in advance,
David H.
I have a procedure that calls several other procedures (some of which are nested within my procedure ... one of the nested procedures is called repeatedly and uses ent_extent without any problems). The section of code below occurs toward the end of my procedure.
- If I comment out the ent_extent call on line 25 then there is no crash (as expected the subsequent drag box does not display correctly but otherwise no problems).
- if I leave the ent_extent call in the code then it returns correct values for botleft and topright, and the code continues to process correctly until the end of the procedure is reached. At the end of the procedure DataCAD becomes unresponsive (for several seconds on my rather slow laptop) and then crashes (the whole program exits, not just the current drawing).
Code: Select all
00 // report entities have been created, but now need to be placed in the correct positions on the drawing
01 for row := 0 to ReportRows.Count-1 do begin
02 for col := 1 to 10 do begin
03 if col = 1 then begin
04 xpos := ReportTopLeft.x;
05 if doLines then
06 xpos := xpos + SpaceLR;
07 end
08 else begin
09 xpos := xpos + ColWidths[col-1] + 2*SpaceLR;
10 end;
11 if ent_get (ent, ReportRows[row].ColAdrs[col]) then begin
12 if (ReportRows[row].RowType in [SUBTOTSROW, TOTSROW]) and (col = ReportRows[row].FirstNonBlank) then begin
13 ent.txtpnt.x := xpos + ColWidths[col];
14 ent.txtpnt.y := ypos;
15 ent.txttype.justification := TEXT_JUST_RIGHT;
16 end
17 else begin
18 ent.txtpnt.x := xpos;
19 ent.txtpnt.y := ypos;
20 end;
21 ent_update (ent);
22 if TopLeftSet then
23 ent_draw (ent, drmode_white)
24 else begin // set report exents for subsequent DragBoxMov when placing report
25 ent_extent (ent, botleft, topright); //ent, botleft, and topright are all locally declared variables
26 l^.Pnt1.x := min (botleft.x, l^.Pnt1.x);
27 l^.Pnt1.y := min (botleft.y, l^.Pnt1.y);
28 l^.Pnt2.x := max (topright.x, l^.Pnt2.x);
29 l^.Pnt2.y := max (topright.y, l^.Pnt2.y);
30 end;
31 end;
32 end;
33
34 ypos := ypos - SpaceBelow[ReportRows[row].RowType];
35 if row < (ReportRows.Count-1) then begin
36 ypos := ypos - SpaceAbove[ReportRows[row+1].RowType] - ReportRows[row+1].RowHeight;
37 end;
38 end;
Don't know if the issue might be a bug with the ent_extent call (it is used is many other places in the macro without any issues), or even a bug with Delphi itself. Both seem unlikely, but I can't see any issues with my code.
Perhaps somebody else may be able to spot an issue or at least throw some light on a possible cause of the crash.
Thanks in advance,
David H.