Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flattento2d! and setcoorddim! need to update the geometry type paramter #333

Open
rafaqz opened this issue Oct 8, 2022 · 1 comment
Open

Comments

@rafaqz
Copy link
Collaborator

rafaqz commented Oct 8, 2022

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.

@mattwigway
Copy link
Contributor

mattwigway commented Jun 6, 2024

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:

  1. 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.
  2. Add a boolean field to the Geometry objects that indicates that the object no longer "owns" its pointer, and check that in destroy
  3. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants