You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just ran into this issue, and was looking at how to fix it. It seems like what needs to happen is that a new Geometry/IGeometry should be constructed and returned based on the pointer. The place I'm running into difficulty is that when the old geometry object is GC'ed on the Julia side, it still has a pointer to the GDAL geometry and will free it, leaving the new geometry pointing at unallocated memory. I can think of three solutions:
Somehow remove the finalizer from the old object. In my tests, calling finalizer(new_function, object) replaces the finalizer rather than adding a second finalizer, but this behavior doesn't seem to be documented, and I am hesitant to rely on it.
Add a boolean field to the Geometry objects that indicates that the object no longer "owns" its pointer, and check that in destroy
Set ptr to a null pointer (or change ptr to a Union{Ptr, Nothing} and set to nothing), and check that in destroy.
I kinda like changing ptr to a Union{Ptr, Nothing} as it avoids accidental dereferencing of null pointers—not sure how it will affect performance though, or backwards compatibility with any serialized ArchGDAL geometries that may exist.
Since we have a type parameter now, changing the type in GDAL is not enough, we need to update the type and return a new object.
The text was updated successfully, but these errors were encountered: