[PyKDE] Re: clone member function deleting object
Paul F. Kunz
Paul_Kunz at slac.stanford.edu
Mon Mar 14 18:28:24 GMT 2005
>>>>> On Mon, 14 Mar 2005 17:55:21 -0000 (GMT), "Phil Thompson" <phil at riverbankcomputing.co.uk> said:
>>>>>>> On Mon, 14 Mar 2005 16:54:49 -0000 (GMT), "Phil Thompson"
>>>>>>> <phil at riverbankcomputing.co.uk> said:
>>
>>> You must either keep a reference or transfer ownership to C++
>>> using sip.transfer() - and make sure you call the C++ dtor
>>> explicitly at some stage to avoid a memory leak.
>> I'll try sip.transfer().
I can't get to the sip documentation pages right now,
river-bank.demon.co.uk not responding. I can see from Python that
sip.transfer takes two arguments. What are they?
>>
>>> What you haven't shown is the Python code that calls clone().
>> No Python code calls clone(). C++ class clone(). With what it
>> gets back, it can display the function graphically and also preform
>> a fitting process against a data set. There are built in C++
>> functions the user can do the same with, but the idea is for the
>> user to provide a custom function in Python.
> So your C++ code that calls clone() does a Py_DECREF() on the
> result?
No. C++ code calls clone() and wants to keep the result for
plotting and fitting. Thus a reference to the Python instance needs
to be keep alive and not garbage collected.
More information about the PyQt
mailing list