QCAD Crash on Entity Copy

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
wildspidee
Full Member
Posts: 84
Joined: Sat Nov 03, 2012 2:00 am

QCAD Crash on Entity Copy

Post by wildspidee » Fri Feb 20, 2015 1:37 am

Andrew,

I found this issue a couple days ago. If you generate a drawing with my script and then try to copy some of the elements, QCAD will crash. It doesn't matter if you are in deBug mode or not, it happens either way.

If you generate the drawing, save it, close the drawing and then reopen, it works just fine. You can copy anything and paste to the same drawing or another. Saving without closing doesn't fix it.

I've attached my FMScripts for you to use. It's not ready for production release, but it works. To generate a drawing off the Fearless Makers menu select Adult Female Patterns > Bodice Front. The file chooser will open and then you can select the Lori0218.xml file, which is located in the xmlFiles folder, also in the FMScripts directory.

Hide the Reference layer, then select everything and try to copy it. I'm on a Mac OSX 10.9.5 and it crashes every single time, it's not intermittent. I haven't tried this in Windows or Linux.

Thanks,
Lori
Attachments
FMScripts.zip
(138.46 KiB) Downloaded 502 times

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: QCAD Crash on Entity Copy

Post by andrew » Fri Feb 20, 2015 9:11 am

The layers that are created by the script reference an invalid linetype (linetypeId is -1).

You can fix the problem by assigning a valid linetype ID to the layers. For example in FMBodiceFront.js:
var linetypeId = gDocument.getLinetypeId("continuous");
var finalLayer = new RLayer(gDocument, 'Pattern', false, false, (new RColor("black")), linetypeId);
...
var refLayer = new RLayer(gDocument, 'Reference', false, false, (new RColor("magenta")), linetypeId);
...
Having said that, invalid linetypeIDs shouldn't lead to a crash. I've fixed this problem for the next release, so you'd only get a warning when copying.

wildspidee
Full Member
Posts: 84
Joined: Sat Nov 03, 2012 2:00 am

Re: QCAD Crash on Entity Copy

Post by wildspidee » Fri Feb 20, 2015 8:36 pm

Worked perfectly.

Thank you Andrew.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”