Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update connection comparison operator to compare connection sources based on instance ID instead of by pointer #52885

Merged

Conversation

David1Socha
Copy link
Contributor

Similar change to the recently merged PR 52493, which I came across while investigating the unpredictable signal ordering detailed in Issue 35084. PR 52493 fixed comparisons of target between 2 connections, but there is a similar issue comparing source between connections. The current setup compares pointers which results in inconsistent comparison outputs for connections with different sources.

As far as I can tell, there's not currently much impact from how connection sources get compared -- I believe the only current caller of Object::Connection::operator< is SceneState::_parse_connections via conns.sort on line 693 of packed_scene.cpp which gets called while saving scenes, and that method already builds up a list connections one node at a time, so source is always identical between any connections that get compared. So after some testing it doesn't seem like this is actually a cause of the unpredictable signal order described in Issue 35084. But it does seem like the comparison logic here is inaccurate and could potentially cause other problems in the future.

Tested some basic operations on my local build of Godot after this change and all seemed good. I think this connection comparison method would be a good candidate for some unit tests, but I'm not too familiar with how testing works in Godot so I haven't included them for now.

@David1Socha David1Socha requested a review from a team as a code owner September 21, 2021 06:56
@Chaosus Chaosus added this to the 3.4 milestone Sep 21, 2021
@akien-mga akien-mga merged commit 75161d2 into godotengine:3.x Sep 21, 2021
@akien-mga
Copy link
Member

Thanks! And congrats for your first merged Godot contribution 🎉

@David1Socha David1Socha deleted the 3.x_fix_connection_comparison branch September 22, 2021 05:27
@akien-mga
Copy link
Member

Cherry-picked for 3.3.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants