[PyKDE] Re: clone member function deleting object
phil at riverbankcomputing.co.uk
Tue Mar 15 09:09:02 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?
It seems to be back now. If you want to do it in C++ instead then there is
>>>> 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
> 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.
But then it sounds like it is being kept alive (and being leaked) because
you are not explicitly disposing of the reference. What Python API call
are you using to call clone()?
More information about the PyQt