Skip to content

Conversation

@aaronfranke
Copy link
Member

In the current master before this PR, the servers had these functions registered with the name "free_rid":

ClassDB::bind_method(D_METHOD("free_rid", "rid"), &NavigationServer2D::free);
ClassDB::bind_method(D_METHOD("free_rid", "rid"), &NavigationServer3D::free);
ClassDB::bind_method(D_METHOD("free_rid", "rid"), &PhysicsServer2D::free);
ClassDB::bind_method(D_METHOD("free_rid", "rid"), &PhysicsServer3D::free);
ClassDB::bind_method(D_METHOD("free_rid", "rid"), &RenderingDevice::free);
ClassDB::bind_method(D_METHOD("free_rid", "rid"), &RenderingServer::free);
ClassDB::bind_method(D_METHOD("free_rid", "rid"), &TextServer::free_rid);

I was working on some C++ code that uses RenderingServer and trying to make it compatible with both in-engine module code and GDExtension C++ godot-cpp, and I found that the exposed API is different from the internal API for no reason. The name free_rid is clearer and avoids confusion with freeing Objects. Furthermore, TextServer already uses the name free_rid for its internal function.

This PR renames the internal free function on NavigationServer*D, PhysicsServer*D, RenderingDevice, and RenderingServer to free_rid to match the exposed API in GDScript and GDExtension and match TextServer.

Third-party modules can support multiple Godot versions by using free_rid and conditionally having #define free_rid free depending on the Godot version in files that use the modified servers.

Copy link
Member

@Ivorforce Ivorforce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fully agree, it's definitely worth the churn to make APIs consistent in- and externally.
Lately we've been a bit more mindful about API breakage. It would be possible to expose a [[deprecated]] void free function in addition the free_rid to make the transition moother for modules. What do you think?

@Ivorforce Ivorforce removed request for a team June 5, 2025 09:11
@akien-mga akien-mga changed the title Rename server "free" functions to "free_rid" to match exposed API Rename server free functions to free_rid to match exposed API Jun 8, 2025
@aaronfranke aaronfranke requested a review from a team as a code owner June 12, 2025 04:39
@Repiteo Repiteo modified the milestones: 4.5, 4.6 Jun 19, 2025
Copy link
Contributor

@Repiteo Repiteo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stylistic nitpick aside, this looks good!

@aaronfranke aaronfranke requested a review from a team as a code owner July 28, 2025 00:17
@aaronfranke aaronfranke force-pushed the server-free branch 2 times, most recently from 95cb338 to 33a07e9 Compare August 23, 2025 12:16
@Repiteo
Copy link
Contributor

Repiteo commented Sep 18, 2025

Needs rebase

@Repiteo
Copy link
Contributor

Repiteo commented Sep 30, 2025

Needs another rebase 🙃

@aaronfranke
Copy link
Member Author

@Repiteo Rebased and retested.

@Repiteo
Copy link
Contributor

Repiteo commented Sep 30, 2025

I bet you'll never guess what I'm gonna say

@Repiteo Repiteo merged commit 4610e1e into godotengine:master Oct 1, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Oct 1, 2025

Thanks!

@aaronfranke aaronfranke deleted the server-free branch October 1, 2025 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment