The DataCAD Developer Network (DDN) is an online resource for information and support for DCAL® (DataCAD Applications Language) developers as well as anyone interested in creating fonts, toolbars, hatch patterns, or linetypes for use in DataCAD.
#76557 by dhs
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).

Code: Select all00    // 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.
#76572 by dhs
Wed Jun 26, 2019 10:49 pm
Have come across another instance where a call to ent_extent appears to be causing a subsequent crash (same symptoms as before).

In this new instance I was able to do my own extent calculations based on the entity type: fortunately the code only needed to cater for 2d lines and text entities so I based my calculations on points returned by a call to txtbox for text entities, and on linpt1 and linpt2 for 2d line entities.

Replacing the ent_extent call with this new logic fixed the crash, so I am beginning to be pretty certain that there is a bug of some sort in the DCAL ent_extent procedure... (even though I have used it elsewhere in the same macro and those calls are not causing a problem)

Rgds,
David H.

Who is online

Users browsing this forum: No registered users and 16 guests

About DataCAD Forum

The DataCAD Forum is a FREE online community we provide to enhance your experience with DataCAD.

We hope you'll visit often to get answers, share ideas, and interact with other DataCAD users around the world.

DataCAD

Software for Architects Since 1984