The .getData().castToShape() construct ...

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
Premier Member
Posts: 1811
Joined: Wed Sep 27, 2017 4:17 pm

The .getData().castToShape() construct ...

Post by CVH » Mon Mar 22, 2021 2:24 pm

In 2016 you wrote: ... 048#p15048
The Object.getData().castToShape() construct is generally not a good idea since a data object
is created (but not used) and a pointer to it's shape is retrieved which is well used.
The data object will get deleted by the garbage collector and the pointer will become invalid.

Launched a textual search on the use of '.castToShape()' in my scripts ...
Missed the correct button and the search was in all files. :lol:

Found the construction here:
  • HatchFromSelection.js: HatchFromSelection.traverse() 3x
    Explode.js: Explode.explodeEntity 4x
    qcadscripts.dll: InfoPolylineArea.prototype.pickEntity
Occurred also plenty in my scripts as I have copied the 'shorter' method literally. :oops:


Post Reply

Return to “QCAD Programming, Script Programming and Contributing”