Skip to content

Commit

Permalink
(try to) fix setter
Browse files Browse the repository at this point in the history
  • Loading branch information
0x53A committed Nov 7, 2024
1 parent f8fbd6d commit d72e5e2
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions godot-macros/src/class/data_models/field_var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,22 +212,21 @@ impl GetterSetterImpl {
fn #function_name(&mut self, #field_name: <#field_type as ::godot::meta::GodotConvert>::Via)
};

let notify_block = match notify {
let function_body_set = quote! {
<#field_type as ::godot::register::property::Var>::set_property(&mut self.#field_name, #field_name);
};

function_body = match notify {
Some(ident) => {
quote! {
if self.#field_name != #field_name {
let prev_value = self.#field_name;
#function_body_set
if prev_value != self.#field_name {
self.#ident();
}
}
},
None => {
quote! { }
}
};

function_body = quote! {
<#field_type as ::godot::register::property::Var>::set_property(&mut self.#field_name, #field_name);
#notify_block
None => function_body_set
};
}
}
Expand Down

0 comments on commit d72e5e2

Please sign in to comment.