[PyQt] Query on signature of %VirtualCatcherCode

Phil Thompson phil at riverbankcomputing.com
Fri May 5 14:58:50 BST 2017


On 4 May 2017, at 9:00 am, Shaheed Haque <srhaque at theiet.org> wrote:
> 
> Hi,
> 
> I am trying to generate the correct SIP %VirtualCatcherCode for this method:
> 
>    Syndication::SpecificDocumentPtr parse(
>        const Syndication::DocumentSource &source) const Q_DECL_OVERRIDE;
> 
> At present the SIP looks like this:
> 
>    virtual Syndication::SpecificDocument *parse(const
> Syndication::DocumentSource &source) const
>        [QSharedPointer<Syndication::SpecificDocument> (const
> Syndication::DocumentSource &source)];
> %MethodCode
> ...
> %End
> %VirtualCatcherCode
> ...
> %End
> 
> And SIP generates the following prototype for the virtual catcher code:
> 
> =================
> QSharedPointer<Syndication::SpecificDocument>
> sipVH_Atom_0(sip_gilstate_t sipGILState, sipVirtErrorHandlerFunc
> sipErrorHandler, sipSimpleWrapper *sipPySelf, PyObject *sipMethod,
> const Syndication::DocumentSource& a0)
> {
>    QSharedPointer<Syndication::SpecificDocument> sipRes = 0;
>    int sipIsErr = 0;
> ...
> =================
> 
> The C++ compiler, not unreasonably, complains about the initialisation
> of sipRes with an integer 0. Now, I suspect the real culprit here is
> the QSharedPointer. AFAIK, this (and its various related classes) has
> no direct representation in PyQt5; this is reflected in the use of the
> dual-signature Python-versus-C++ facility in SIP and the %MethodCode I
> generate.
> 
> I'm just trying to figure out what I need to write in my
> %VirtualCatcherCode, but it is not clear to me how to handle this
> error. Have I misunderstood the SIP dual-signature thing as it applies
> in this case?
> 
> Any insights gratefully received.

It's a bug - triggered by the returned value being a template.

Patch attached.

Phil

-------------- next part --------------
A non-text attachment was scrubbed...
Name: sip.patch
Type: application/octet-stream
Size: 512 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170505/d3146be1/attachment.obj>


More information about the PyQt mailing list