Skip to content

Commit

Permalink
Workarounds for crashes at engine startup
Browse files Browse the repository at this point in the history
These are likely related to refcounting issues.
The change in the SConstruct script fixes a crash that occured somewhere in `bind_get_argument_type` when registering classes and binding methods.
Commenting out the `delete`s in destructors fixed a `double free or corruption` crash that occured after the fix described above.

Likely related to godotengine/godot-cpp#652, but neither godotengine/godot-cpp#660 or godotengine/godot-cpp#662 seemed to help...
  • Loading branch information
kb173 committed Feb 3, 2022
1 parent 07fb6fe commit 43e2a6b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
3 changes: 3 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ subprocess.call(

env.Append(CXXFLAGS=['-std=c++17'])

if env["target"] == "debug":
env.Append(CPPDEFINES=["DEBUG_ENABLED", "DEBUG_METHODS_ENABLED"])

# Check our platform specifics
if env['platform'] == "osx":
env['target_path'] += 'osx/'
Expand Down
4 changes: 2 additions & 2 deletions src/geodata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace godot {

GeoDataset::~GeoDataset() {
delete dataset;
// delete dataset;
}

void GeoDataset::_bind_methods() {
Expand Down Expand Up @@ -201,7 +201,7 @@ void GeoFeatureLayer::set_native_layer(NativeLayer *new_layer) {
}

GeoRasterLayer::~GeoRasterLayer() {
delete dataset;
// delete dataset;
}

void GeoRasterLayer::_bind_methods() {
Expand Down
2 changes: 1 addition & 1 deletion src/geoimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using namespace godot;
// Geodot::GeoImage

GeoImage::~GeoImage() {
delete raster;
// delete raster;
}

void GeoImage::_bind_methods() {
Expand Down
6 changes: 2 additions & 4 deletions src/vector-extractor/VectorExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,13 @@ std::list<LineFeature *> NativeLayer::crop_lines_to_square(const char *path, dou
return list;
}

NativeDataset::~NativeDataset() {}

NativeDataset *NativeDataset::get_subdataset(const char *name) {
// TODO: Hardcoded for the way GeoPackages work - do we want to support others too?
return new NativeDataset(("GPKG:" + path + ":" + std::string(name)).c_str());
return new NativeDataset(("GPKG:" + std::string(path) + ":" + std::string(name)).c_str());
}

NativeDataset *NativeDataset::clone() {
return new NativeDataset(path.c_str());
return new NativeDataset(path);
}

bool NativeDataset::is_valid() const {
Expand Down
4 changes: 2 additions & 2 deletions src/vector-extractor/VectorExtractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class GDALDataset;
class NativeDataset {
public:
NativeDataset(const char *path);
~NativeDataset();
~NativeDataset() = default;

/// Return the names of all feature layers as std::strings.
std::vector<std::string> get_feature_layer_names();
Expand All @@ -31,7 +31,7 @@ class NativeDataset {

bool is_valid() const;

std::string path;
const char *path;

GDALDataset *dataset;
};
Expand Down

0 comments on commit 43e2a6b

Please sign in to comment.