[PyQt] Classes with private destructors get subclassed by SIP

Shaheed Haque srhaque at theiet.org
Tue Jun 13 17:44:06 BST 2017


Given a SIP class like this (c.f. KF5/KIOWidgets/kautomount.h):

class PrivateDestructor
    PrivateDestructor() {};
    virtual ~PrivateDestructor() {};
    PrivateDestructor(const PrivateDestructor &) {};

SIP ends up creating a subclass which, if I am reading StackOverflow
correclty, is not allowed because of the private destructor. That
inevitably leads to errors from the compiler like this:

In file included from unifiedPySample.cpp:1:0:
error: deleted function ‘virtual
 class sipPrivateDestructor : public  ::PrivateDestructor
In file included from /tmp/tmpwxNqBS/tmp2/sip/PySample/sample1.sip:26:0,
                 from sipPySamplePrivateDestructor.cpp:40,
                 from unifiedPySample.cpp:1:
error: overriding non-deleted function ‘virtual
     virtual ~PrivateDestructor() {};

and so on and so on. Perhaps the logic for triggering a subclass needs
to exclude this case?

Thanks, Shaheed

P.S. On a separate-but-related matter, if this area of the code is
indeed the area that needs to be modified, for the case where SIP
determines that a subclass is NOT required, it would be really handy
for me if SIP were to provide a macro like this:

#define sipPrivateDestructor PrivateDestructor

The point being that my machine-generated "hand-written" code can be
written in terms of sipPrivateDestructor, whereas now, in every such
case, I have to add the #define from custom logic.

More information about the PyQt mailing list