[PyKDE] Re: clone member function deleting object

Phil Thompson phil at riverbankcomputing.co.uk
Mon Mar 14 15:34:04 GMT 2005


>>>>>> On Thu, 3 Mar 2005 09:17:07 -0000 (GMT), "Phil Thompson"
>>>>>> <phil at riverbankcomputing.co.uk> said:
>
>    Enabling tracing with SIP, I get the following when I call the
> clone() member function in C++...
>
> FunctionBase * sipFunctionBase::clone() const (this=0x083b0878)
> python.clone
> sipFunctionBase::sipFunctionBase(const FunctionBase&) (this=0x0842b2d8)
> python.copy
> sipFunctionBase::~sipFunctionBase() (this=0x0842b2d8)

This isn't very helpful unless it shows your Python debug print statements
so that you can see the exact order that things are happening.

> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1075068096 (LWP 12449)]
> 0x41abf5d8 in FunctionProjector::initializeFunction (this=0x8403940,
>     projector=0xbfffe4f0)
>     at ../../hippodraw/projectors/FunctionProjector.cxx:135
> Current language:  auto; currently c++
> (gdb)
>
> The Python code looks like ...
>
> from sihippo import FunctionBase
> class Linear ( FunctionBase ) :
>     def __init__ ( self, other = None ) :
>         if other :
>             FunctionBase.__init__( self, other )
>             print "python.copy"
>             self.initialize ()
>         else:
>             FunctionBase.__init__( self )
>             print "python.default"
>             self.initialize ()
>
>     def clone ( self ) :
>         print "python.clone"
>         return Linear ( self )
>
>
> The segmenetation fault above occurs when I try to use the cloned
> function from C++.  It appears that SIP is destroying the clone
> function when returning from the clone member function implemented in
> Python.

Obviously it will do this if you aren't saving the result of the call to
clone().

>    What might I try next?

Additional debug statements to see exactly which Python statement the dtor
is being called from.

Phil




More information about the PyQt mailing list