Python DeleteStructure crashes on DRAWSEGMENT

Bug #1719227 reported by Greg Smith
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
Invalid
Undecided
Unassigned

Bug Description

It probably happens on other objects as well.

When calling DeleteStructure on an object, KiCad occasionally crashes.

[pcbnew.GetBoard().GetDrawings()][0].DeleteStructure()

An apparently better way to remove S_SEGMENTS is:
pcbnew.GetBoard().GetDrawings().Remove(segment)

rather than:
segment.DeleteStructure()

Application: kicad
Version: (2017-08-27 revision e3c64f1f0)-makepkg, release build
Libraries:
    wxWidgets 3.0.3
    libcurl/7.54.1 OpenSSL/1.0.2l zlib/1.2.11 libssh2/1.8.0 nghttp2/1.23.1 librtmp/2.3
Platform: Windows 7 (build 7601, Service Pack 1), 64-bit edition, 64 bit, Little endian, wxMSW
Build Info:
    wxWidgets: 3.0.3 (wchar_t,wx containers,compatible with 2.8)
    Boost: 1.60.0
    Curl: 7.54.1
    KiCad compiler: GCC 7.1.0 with C++ ABI 1011
Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=OFF
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

I'm not sure this is a bug other than the fact the drawing object list is exposed and open to abuse. It should be private so you cannot do this or at least you should be restricted to iterating over the list in Python. You probably should be using BOARD::Remove() rather than BOARD::GetDrawings().Remove() to remove objects from the BOARD object.

Revision history for this message
Jeff Young (jeyjey) wrote :

Will this be fixed by Miles' recent patch?

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

I don't think Miles` patch will fix this because GetDrawings() is still exposed so it's open to abuse. Removing this from the python api will likely break user's scripts so I don't think that's an option. I'm going to set the status of this to invalid since there is not much we can do to prevent users from abusing this. Hopefully someone will step up and wrap this code to safely delete objects from the BOARD object.

Changed in kicad:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.