[QGIS-Developer] Is it just me, or is sip totally broken?
Alessandro Pasotti
apasotti at gmail.com
Fri Jan 4 00:45:11 PST 2019
It's not just you, this is what I see when running your code:
WTFFFFFFF!!!
Found PyQt5 version: 5.11.2
Found SIP version: 4.19.13
On Thu, Jan 3, 2019 at 8:19 AM Nyall Dawson <nyall.dawson at gmail.com> wrote:
> Hi list,
>
> I'm at my wits end here, fighting with a sip issue I can't solve. And
> honestly, I'm starting to think maybe there's something completely
> broken in sip. (Or at least, in the version 4.19.7 provided by my
> distro).
>
> Here's what I'm currently hitting:
>
> The validity check registry added this week has a method "addCheck",
> which transfers ownership of the check to c++:
>
> void addCheck( QgsAbstractValidityCheck *check SIP_TRANSFER );
>
> https://github.com/qgis/QGIS/blob/master/src/core/validity/qgsvaliditycheckregistry.h#L65
>
> But if I make a Python subclass of QgsAbstractValidityCheck, and add
> it to the registry, it's immediately garbage collected by Python!
>
> My test code looks like this:
>
> class LayoutMapCrsCheck(QgsAbstractValidityCheck):
>
> def __del__(self):
> print('WTFFFFFFF!!!')
>
> def id(self):
> return 'map_crs_check'
>
> def checkType(self):
> return QgsAbstractValidityCheck.TypeLayoutCheck
>
> def prepareCheck(self,context, feedback):
> return True
>
> def runCheck(self,context, feedback):
> return []
>
> def add_check():
> QgsApplication.validityCheckRegistry().addCheck(LayoutMapCrsCheck())
>
> add_check()
>
>
> So I create a Python subclass of the interface, and then add it to the
> registry. And boom - it's immediately deleted.
>
> If I make a global copy of the check, and then add to the registry,
> everything works -- the check isn't garbage collected.
>
> check_instance = LayoutMapCrsCheck()
> QgsApplication.validityCheckRegistry().addCheck(check_instance)
>
> But this leads me to believe that sip is broken somewhere, and is
> ignoring the /Transfer/ annotation.
>
> Indeed - I've also seen this in other classes. Specifically
> QgsTaskManager.addTask() -- Python tasks must be stored globally in
> order to avoid them being immediately deleted too.
>
> Can anyone else reproduce using my above code? Does anyone have any
> ideas what's happening here?
>
> Nyall
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
--
Alessandro Pasotti
w3: www.itopen.it
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190104/e1a134b0/attachment.html>
More information about the QGIS-Developer
mailing list