boku-ilen / geodot-plugin

Godot plugin for loading geospatial data
GNU General Public License v3.0
108 stars 18 forks source link

Destructor called too early when chaining get_database and get_layer #59

Closed kb173 closed 1 year ago

kb173 commented 3 years ago

Sometimes it would be convenient to chain Geodot calls like this:

var layer = Geodot.get_dataset(path).get_layer(name)

But this produces an error: The resulting layer does not point to a valid OGRLayer, so the program crashes. A workaround is to do this:

var dataset = Geodot.get_dataset(path)
var layer = dataset.get_layer(name)

It seems like when chaining, some destructor is called too early. I assume the dataset gets deleted, so the layer doesn't point to anything valid anymore.

kb173 commented 3 years ago

A hotfix was pushed in https://github.com/boku-ilen/geodot-plugin/commit/910242285d6a2b6424d561e245bbfb28fa29e83b, but these destructor calls need to be re-implemented properly!

kb173 commented 1 year ago

Fixed by smart pointers in e44a349 and proper destructor re-implementations in bdd82f1