Skip to content

Commit

Permalink
Update to godot-cpp 9eceb16f0553884094d0f659461649be5d333866.
Browse files Browse the repository at this point in the history
As of `godot-cpp` 9eceb16f0553884094d0f659461649be5d333866 a
number of fixes have been incorporated that mean `Ref<>`s are no
longer leaked and `PoolByteArray`/`PoolStringArray`s are also
no longer leaked when passed as arguments to GDNative functions.

The one(?) downside is that the `Ref<>` workaround that *was*
necessary...now causes a crash. *sigh*

Originally I thought `godot-cpp` latest (~3.2 but it's not on the
3.2 branch, yet) didn't work with Godot 3.1.x but it turned out
that the "mysterious load error" that occurred was Godot not
finding the test script! Apparently the "current directory" is
calculated different in Godot 3.1.x than 3.2.x but the error
returned wasn't stated as "file not found".

Because of what I thought was an incompatibility I figured out
how to get `godot-cpp` 3.1 to also not leak memory and while
that's not actually necessary now I thought I'd at least commit it,
at least temporarily, hence the conditionals. (Not yet committed.)

But the upshot is, this commit will probably be broken or leak
memory when compiled against `godot-cpp` 3.1 but should be good
for `godot-cpp` @ the mentioned ref.

More details: <godotengine/godot-cpp#417>
  • Loading branch information
follower committed Jun 24, 2020
1 parent cd0238c commit 9ee3d9a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/foreigner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ Ref<ForeignBuffer> Foreigner::new_buffer(uint32_t size_in_bytes) {
ForeignBuffer *the_buffer = ForeignBuffer::_new();
the_buffer->_init_buffer(size_in_bytes);

#if defined(TARGET_GODOT_CPP_3_2_LATEST)
Ref<ForeignBuffer> ref = Ref<ForeignBuffer>(the_buffer);
#else
Ref<ForeignBuffer> ref = Ref<ForeignBuffer>::__internal_constructor(the_buffer);
#endif
return ref;

}
Expand Down Expand Up @@ -57,7 +61,11 @@ Ref<ForeignLibrary> Foreigner::open(String path) {
}

ForeignLibrary *library = ForeignLibrary::_new();
#if defined(TARGET_GODOT_CPP_3_2_LATEST)
Ref<ForeignLibrary> ref = Ref<ForeignLibrary>(library);
#else
Ref<ForeignLibrary> ref = Ref<ForeignLibrary>::__internal_constructor(library);
#endif
library->setHandle(handle);
return ref;
}
Expand Down
2 changes: 2 additions & 0 deletions src/foreigner.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include "foreignbuffer.h"

#define TARGET_GODOT_CPP_3_2_LATEST // 9eceb16f0553884094d0f659461649be5d333866

namespace godot {

class Foreigner : public Reference {
Expand Down

0 comments on commit 9ee3d9a

Please sign in to comment.