diff --git a/pcbnew/scripting/TODO.txt b/pcbnew/scripting/TODO.txt index 73a348546d..ff1cfe20e5 100644 --- a/pcbnew/scripting/TODO.txt +++ b/pcbnew/scripting/TODO.txt @@ -1,11 +1,14 @@ +* add MODULE::Add (see BOARD:Add), to make it more clean -* Tell swig(somehow) to forget automatic object deletion after adding - a BOARD_ITEM to BOARD object (it will be automatically deleted by BOARD, +* Tell swig to forget automatic object deletion after adding + a BOARD_ITEM to MODULE object (it will be automatically deleted by MODULE, leading to Segmentation Fault when unloading our python module (double free). -* implement iterator for NETCLASSES (NETCLASS) see class_netclass.h - -* add MODULE::Add (see BOARD:Add), to make it more clean + It seems that we must do object.thisown=0 when added, may be adding a wrapper + Add function. + + +* Implement iterator for NETCLASSES (NETCLASS) see class_netclass.h * Saving modules to library (in librairi.cpp) @@ -22,5 +25,6 @@ to kicad plugin? - + void PCB_EDIT_FRAME::ArchiveModulesOnBoard( const wxString& aLibName, bool aNewModulesOnly ) + diff --git a/pcbnew/scripting/board.i b/pcbnew/scripting/board.i index b482c4ce84..18449934bd 100644 --- a/pcbnew/scripting/board.i +++ b/pcbnew/scripting/board.i @@ -45,6 +45,15 @@ def Save(self,filename): return SaveBoard(filename,self) + + # + # add function, clears the thisown to avoid python from deleting + # the object in the garbage collector + # + + def Add(self,item): + item.thisown=0 + self.AddNative(item) } } @@ -57,6 +66,7 @@ %rename(Get) operator MODULE*; %rename(Get) operator SEGZONE*; + // we must translate C++ templates to scripting languages %template(BOARD_ITEM_List) DLIST; diff --git a/pcbnew/scripting/pcbnew.i b/pcbnew/scripting/pcbnew.i index b62e56cd7b..f45011650e 100644 --- a/pcbnew/scripting/pcbnew.i +++ b/pcbnew/scripting/pcbnew.i @@ -36,6 +36,8 @@ %ignore BOARD_ITEM::ZeroOffset; %ignore D_PAD::m_PadSketchModePenSize; +%rename(AddNative) *::Add; + // this is what it must be included in the wrapper .cxx code to compile %{ diff --git a/scripting/kicad.i b/scripting/kicad.i index 01b75278f3..08d65c20ee 100644 --- a/scripting/kicad.i +++ b/scripting/kicad.i @@ -55,7 +55,7 @@ %rename(getWxRect) operator wxRect; %ignore operator <<; -%ignore operator =; +%ignore operator=; %{