Repository navigation
Improve logic around using Ref<T> with GDExtension virtual functions - #69902
Merged
akien-mga merged 1 commit intoDec 14, 2022
Merged
Conversation
BastiaanOlij
force-pushed
the
improve_gdextension_virtual_ref
branch
2 times, most recently
from
December 11, 2022 11:04
338bffd to
787ca6e
Compare
Contributor
Author
|
Note that we're using the new naming convention using GDExtension instead of GDNative (pending PR) |
Contributor
|
For me, this pair of PR's solved random crash when repeatedly transferring a native class from |
DmitriySalnikov
added a commit
to DmitriySalnikov/godot_debug_draw_3d
that referenced
this pull request
Dec 12, 2022
restored groupedText renderer added Ref<T> patch. Need godotengine/godot#69902 to work
BastiaanOlij
force-pushed
the
improve_gdextension_virtual_ref
branch
2 times, most recently
from
December 12, 2022 23:34
77c1e8d to
a1b5dbb
Compare
BastiaanOlij
force-pushed
the
improve_gdextension_virtual_ref
branch
from
December 12, 2022 23:55
a1b5dbb to
7502e1d
Compare
akien-mga
approved these changes
Dec 14, 2022
Member
|
Thanks! |
migueldeicaza
added a commit
to migueldeicaza/SwiftGodot
that referenced
this pull request
Jan 9, 2026
migueldeicaza
added a commit
to migueldeicaza/SwiftGodot
that referenced
this pull request
Jan 9, 2026
… Ref<> virtual returns (#759) * Changed the generated virtual method return handling so that when a virtual returns a RefCounted (for Resource), we write a proper Ref<> via ref_set_object instead of writing a raw Object* handle. I was observing that overwritten methods in GDScript that returned Resource-derived types were returning nil. * Add method, this is to support the special ABI in godotengine/godot#69902
csueiras
pushed a commit
to cafecito-games/SwiftGodot
that referenced
this pull request
May 9, 2026
… Ref<> virtual returns (#759) * Changed the generated virtual method return handling so that when a virtual returns a RefCounted (for Resource), we write a proper Ref<> via ref_set_object instead of writing a raw Object* handle. I was observing that overwritten methods in GDScript that returned Resource-derived types were returning nil. * Add method, this is to support the special ABI in godotengine/godot#69902
BendyLand
pushed a commit
to BendyLand/voltaire
that referenced
this pull request
Aug 2, 2026
…nsion_virtual_ref Improve logic around using Ref<T> with GDExtension virtual functions
BendyLand
pushed a commit
to BendyLand/voltaire
that referenced
this pull request
Aug 2, 2026
…nsion_virtual_ref Improve logic around using Ref<T> with GDExtension virtual functions
wangshucheng
pushed a commit
to wangshucheng/godot
that referenced
this pull request
Aug 27, 2026
…nsion_virtual_ref Improve logic around using Ref<T> with GDExtension virtual functions
Shane-Gadsby
pushed a commit
to Shane-Gadsby/godotwebgpu
that referenced
this pull request
Sep 21, 2026
…nsion_virtual_ref Improve logic around using Ref<T> with GDExtension virtual functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As discussed during the GDExtension meeting, we have a problem when calling GDExtension virtual functions when
Ref<T>is used as the data type. Unlike "normal" functions, which useVirtualas an intermediate which ensures refcounting is done, with virtual functions we send pointers toRef<T>objects. Unfortunately GDExtension can't make heads nor tails of this and right now we assign values in a rather dangerous way as well as introducing the risk of returned objects being destroyed before Godot is able to reference them.This PR introduces two support functions that allow us to get or set an object on a Godot side
Ref<T>pointer.This PR has a companion PR on the godot-cpp side which uses these functions: godotengine/godot-cpp#958