[QGIS-Developer] Fw: [ccrook/QGIS-Contour-Plugin] RuntimeError : wrapped C/C++ object of type ContourGeneratorAlgorithm has been deleted (Issue #46)
Nyall Dawson
nyall.dawson at gmail.com
Sun Dec 4 15:51:21 PST 2022
On Mon, 5 Dec 2022 at 07:35, Chris Crook via QGIS-Developer
<qgis-developer at lists.osgeo.org> wrote:
>
> Hi Developers
>
> The contour plugin I have been maintaining seems to occasionally lose the C++ object that its processing algorithm is using.
> In particular this happens when changing settings.
>
> Before I get lost trying to track this through the Python/SWIG bindings and comparing with other processing algorithms I am wondering if this is familiar or you can offer ideas about how to track it down. It seems either my python object is persisting too long or or the underlying C++ object not long enough, but I'm very unfamiliar with SWIG so any suggestions would be very welcome 🙂
There's a bug in your loadAlgorithms() implementation. In this you
need to create a NEW instance of each algorithm, rather then adding an
instance which has previously been add in an earlier call to
loadAlgorithms().
Ie DON'T do this:
def __init__(self):
self.algs = [MyAlgorithm()]
def loadAlgorithms(self):
for alg in self.algs:
self.addAlgorithm(alg)
Rather do something like this:
def loadAlgorithms(self):
for alg in [MyAlgorithm()]:
self.addAlgorithm(alg)
(or alternatively:
def __init__(self):
self.alg_classes = [MyAlgorithm]
def loadAlgorithms(self):
for alg_class in self.alg_classes:
self.addAlgorithm(alg_class())
)
Hope that helps!
Nyall
>
> Thanks
> Chris
> ________________________________
> From: Taras Dubrava <notifications at github.com>
> Sent: 04 December 2022 01:11
> To: ccrook/QGIS-Contour-Plugin <QGIS-Contour-Plugin at noreply.github.com>
> Cc: Subscribed <subscribed at noreply.github.com>
> Subject: [ccrook/QGIS-Contour-Plugin] RuntimeError : wrapped C/C++ object of type ContourGeneratorAlgorithm has been deleted (Issue #46)
>
>
> Every time when I change the background colour in QGIS the following error appears
>
> QGIS 3.28 Firenze
>
> —
> Reply to this email directly, view it on GitHub, or unsubscribe.
> You are receiving this because you are subscribed to this thread.Message ID: <ccrook/QGIS-Contour-Plugin/issues/46 at github.com>
>
>
> ________________________________
>
> This message contains information, which may be in confidence and may be subject to legal privilege. If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message. If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message. LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ. Thank You.
> _______________________________________________
> 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
More information about the QGIS-Developer
mailing list