*> The underlying C++ code expects a pointer to the reference layer. If the
python wrapper just passes the pointer of the object that was created in
the call, the object will be out of scope after the function call returns
and will be garbage collected. Someone who actually knows the code details
can verify or contradict this.*

This makes sense to me.
In fact, the original code makes QGIS crash (using v3.28.6) with a
Segmentation Fault, indicating that the underlying C++ object has been
deleted.
That's why you should first create a Python variable to make it clear that
the layer object should persist in the outer scope.

Regards,

Germán


El vie, 20 oct 2023 a las 5:30, David Strip (<qgis-u...@stripfamily.net>)
escribió:

> On 10/19/2023 10:32 AM, Gabriel De Luca via QGIS-Developer wrote:
>
> Hi German,
>
>   Thanks. Yes, it works that way. Do you know why?
>
>
> Regards,
> Gabriel
>
>
> Since nobody who really knows the code has responded yet, I'll conjecture
> it's a scoping issue. The underlying C++ code expects a pointer to the
> reference layer. If the python wrapper just passes the pointer of the
> object that was created in the call, the object will be out of scope after
> the function call returns and will be garbage collected. Someone who
> actually knows the code details can verify or contradict this.
>


-- 
-----------
   |\__
(:>__)(
   |/
Soluciones Geoinformáticas Libres
http://geotux.tuxfamily.org/
https://twitter.com/GeoTux2 <http://twitter.com/GeoTux2>

<http://gis.stackexchange.com/users/4972/germ%c3%a1n-carrillo>
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to