BOARD::Add now it's wrapped in python and clears the .thisown flag on python to avoid GC from deleting the object later (BOARD will do)

This commit is contained in:
Miguel Angel Ajo 2012-04-06 21:46:45 +02:00
parent 173b869dcb
commit 96c1a50e00
4 changed files with 23 additions and 7 deletions

View File

@ -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 * Tell swig to forget automatic object deletion after adding
a BOARD_ITEM to BOARD object (it will be automatically deleted by BOARD, a BOARD_ITEM to MODULE object (it will be automatically deleted by MODULE,
leading to Segmentation Fault when unloading our python module (double free). leading to Segmentation Fault when unloading our python module (double free).
* implement iterator for NETCLASSES (NETCLASS) see class_netclass.h It seems that we must do object.thisown=0 when added, may be adding a wrapper
Add function.
* add MODULE::Add (see BOARD:Add), to make it more clean
* Implement iterator for NETCLASSES (NETCLASS) see class_netclass.h
* Saving modules to library (in librairi.cpp) * Saving modules to library (in librairi.cpp)
@ -22,5 +25,6 @@
to kicad plugin? to kicad plugin?
void PCB_EDIT_FRAME::ArchiveModulesOnBoard( const wxString& aLibName, bool aNewModulesOnly )

View File

@ -45,6 +45,15 @@
def Save(self,filename): def Save(self,filename):
return SaveBoard(filename,self) 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 MODULE*;
%rename(Get) operator SEGZONE*; %rename(Get) operator SEGZONE*;
// we must translate C++ templates to scripting languages // we must translate C++ templates to scripting languages
%template(BOARD_ITEM_List) DLIST<BOARD_ITEM>; %template(BOARD_ITEM_List) DLIST<BOARD_ITEM>;

View File

@ -36,6 +36,8 @@
%ignore BOARD_ITEM::ZeroOffset; %ignore BOARD_ITEM::ZeroOffset;
%ignore D_PAD::m_PadSketchModePenSize; %ignore D_PAD::m_PadSketchModePenSize;
%rename(AddNative) *::Add;
// this is what it must be included in the wrapper .cxx code to compile // this is what it must be included in the wrapper .cxx code to compile
%{ %{

View File

@ -55,7 +55,7 @@
%rename(getWxRect) operator wxRect; %rename(getWxRect) operator wxRect;
%ignore operator <<; %ignore operator <<;
%ignore operator =; %ignore operator=;
%{ %{