-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Merged by Bors] - make register
on TypeRegistry
idempotent
#6487
[Merged by Bors] - make register
on TypeRegistry
idempotent
#6487
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I think we may eventually want to add methods for overwriting registrations or removing type data so users can opt out of registrations made by other crates, but that can wait.
bors r+ |
# Objective - adding a new `.register` should not overwrite old type data - separate crates should both be able to register the same type I ran into this while debugging why `register::<Handle<T>>` removed the `ReflectHandle` type data from a prior `register_asset_reflect`. ## Solution - make `register` do nothing if called again for the same type - I also removed some unnecessary duplicate registrations
register
on TypeRegistry
idempotentregister
on TypeRegistry
idempotent
@@ -87,6 +87,10 @@ impl TypeRegistry { | |||
|
|||
/// Registers the type described by `registration`. | |||
pub fn add_registration(&mut self, registration: TypeRegistration) { | |||
if self.registrations.contains_key(®istration.type_id()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should probably more intelligently merge the type data of the registration without overwriting existing data/registrations rather than skipping, but for now I'm fine with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed here, but that can come later.
# Objective - adding a new `.register` should not overwrite old type data - separate crates should both be able to register the same type I ran into this while debugging why `register::<Handle<T>>` removed the `ReflectHandle` type data from a prior `register_asset_reflect`. ## Solution - make `register` do nothing if called again for the same type - I also removed some unnecessary duplicate registrations
Objective
.register
should not overwrite old type dataI ran into this while debugging why
register::<Handle<T>>
removed theReflectHandle
type data from a priorregister_asset_reflect
.Solution
register
do nothing if called again for the same type