<div dir="ltr"><div dir="ltr"><div dir="ltr"><div><br></div><div>It's not just you, this is what I see when running your code:</div><div>

<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><br></p><p style="margin:0px;text-indent:0px;white-space:pre-wrap">WTFFFFFFF!!!</p><p style="margin:0px;text-indent:0px;white-space:pre-wrap"><br></p><div><br></div><div>

<p style="margin:0px;text-indent:0px;white-space:pre-wrap">Found PyQt5 version: 5.11.2</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">Found SIP version: 4.19.13</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><br></p><p style="margin:0px;text-indent:0px;white-space:pre-wrap"><br></p></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jan 3, 2019 at 8:19 AM Nyall Dawson <<a href="mailto:nyall.dawson@gmail.com">nyall.dawson@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi list,<br>
<br>
I'm at my wits end here, fighting with a sip issue I can't solve. And<br>
honestly, I'm starting to think maybe there's something completely<br>
broken in sip. (Or at least, in the version 4.19.7 provided by my<br>
distro).<br>
<br>
Here's what I'm currently hitting:<br>
<br>
The validity check registry added this week has a method "addCheck",<br>
which transfers ownership of the check to c++:<br>
<br>
void addCheck( QgsAbstractValidityCheck *check SIP_TRANSFER );<br>
<a href="https://github.com/qgis/QGIS/blob/master/src/core/validity/qgsvaliditycheckregistry.h#L65" rel="noreferrer" target="_blank">https://github.com/qgis/QGIS/blob/master/src/core/validity/qgsvaliditycheckregistry.h#L65</a><br>
<br>
But if I make a Python subclass of QgsAbstractValidityCheck, and add<br>
it to the registry, it's immediately garbage collected by Python!<br>
<br>
My test code looks like this:<br>
<br>
class LayoutMapCrsCheck(QgsAbstractValidityCheck):<br>
<br>
    def __del__(self):<br>
        print('WTFFFFFFF!!!')<br>
<br>
    def id(self):<br>
        return 'map_crs_check'<br>
<br>
    def checkType(self):<br>
        return QgsAbstractValidityCheck.TypeLayoutCheck<br>
<br>
    def prepareCheck(self,context, feedback):<br>
        return True<br>
<br>
    def runCheck(self,context, feedback):<br>
        return []<br>
<br>
def add_check():<br>
    QgsApplication.validityCheckRegistry().addCheck(LayoutMapCrsCheck())<br>
<br>
add_check()<br>
<br>
<br>
So I create a Python subclass of the interface, and then add it to the<br>
registry. And boom - it's immediately deleted.<br>
<br>
If I make a global copy of the check, and then add to the registry,<br>
everything works -- the check isn't garbage collected.<br>
<br>
check_instance = LayoutMapCrsCheck()<br>
QgsApplication.validityCheckRegistry().addCheck(check_instance)<br>
<br>
But this leads me to believe that sip is broken somewhere, and is<br>
ignoring the /Transfer/ annotation.<br>
<br>
Indeed - I've also seen this in other classes. Specifically<br>
QgsTaskManager.addTask() -- Python tasks must be stored globally in<br>
order to avoid them being immediately deleted too.<br>
<br>
Can anyone else reproduce using my above code? Does anyone have any<br>
ideas what's happening here?<br>
<br>
Nyall<br>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a></blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">Alessandro Pasotti<br>w3:   <a href="http://www.itopen.it" target="_blank">www.itopen.it</a></div></div></div>