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

Properties are now registered in order of declaration #777

Merged
merged 1 commit into from
Aug 30, 2021

Conversation

Bromeon
Copy link
Member

@Bromeon Bromeon commented Aug 30, 2021

Older change, not yet merged.

Properties exported via #[property] appear in arbitrary order in the editor, and the order can change on each rustc compilation. This is due to the inner workings of HashMap, which orders its element non-deterministically as a security feature.

This code:

#[derive(gd::NativeClass)]
#[no_constructor]
pub struct GodotGraph {
    #[property] first: i32,
    #[property] second: bool,
    #[property] third: Color,
    #[property] fourth: Vector2,
}

can lead to any of these variants:

one
two
three

This PR makes the order follow the declaration order, by using Vec instead of HashMap.

bors try

bors bot added a commit that referenced this pull request Aug 30, 2021
@Bromeon Bromeon added bug c: export Component: export (mod export, derive) labels Aug 30, 2021
@bors
Copy link
Contributor

bors bot commented Aug 30, 2021

try

Build succeeded:

@Bromeon
Copy link
Member Author

Bromeon commented Aug 30, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented Aug 30, 2021

Build succeeded:

@bors bors bot merged commit 633c8c7 into godot-rust:master Aug 30, 2021
@Bromeon Bromeon deleted the bugfix/ordered-properties branch August 30, 2021 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug c: export Component: export (mod export, derive)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant