[PyQt] [SIP] wrap a class with protected destructor

Phil Thompson phil at riverbankcomputing.com
Wed Nov 25 18:42:07 GMT 2009


On Mon, 23 Nov 2009 10:01:45 +0100, Sébastien Petitdemange
<sebastien.petitdemange at esrf.fr> wrote:
> Hi List,
> 
> I try to use the new release of sip (4.9.2) and I notice that destructor
> wrapping is different from sip 4.7.9. And I have a compilation error:
> 
> sip 4.9.2 generate this for the destructor:
> 
> static void release_SinkTaskBase(void *sipCppV,int sipState)
> {
>     SinkTaskBase *sipCpp = reinterpret_cast<SinkTaskBase *>(sipCppV);
> 
> #line 338 "processlib_tmp.sip"
>  Py_BEGIN_ALLOW_THREADS;
>  sipCpp->unref();
>  Py_END_ALLOW_THREADS;
> #line 216 "sipprocesslibSinkTaskBase.cpp"
> 
>     Py_BEGIN_ALLOW_THREADS
> 
>     if (sipState & SIP_DERIVED_CLASS)
>         delete reinterpret_cast<sipSinkTaskBase *>(sipCppV);
>     else
>         delete reinterpret_cast<SinkTaskBase *>(sipCppV);
> 
>     Py_END_ALLOW_THREADS
> }
> 
> and as the SinkTaskBase object has a protected Destructor so the
> compilation failed.
> 
> previously sip 4.7.9 only use the %MethodCode provide so the wrapping
> method look like that:
> 
> static void release_SinkTaskBase(void *sipCppV,int)
> {
>     SinkTaskBase *sipCpp = reinterpret_cast<SinkTaskBase *>(sipCppV);
> #line 338 "processlib_tmp.sip"
>  Py_BEGIN_ALLOW_THREADS;
>  sipCpp->unref();
>  Py_END_ALLOW_THREADS;
> #line 215 "sipprocesslibSinkTaskBase.cpp"
> }
> 
> Is there a way (New key word) to wrap a protected or even private
> destructor ?

You wrap a protected dtor just as you would wrap a public dtor. It looks
like you haven't done this.

Phil


More information about the PyQt mailing list