core: Fix memory leak caused by unbound text variables

Text fields without variables would return as unbound in
EditText::try_bind_text_field_variable, causing them to be added
to the unbound textfield list even though they had no variable
setting. Return successful bidning by default to avoid adding
these textfields to the unbound list.
This commit is contained in:
Mike Welsh 2020-12-29 13:10:08 -08:00
parent 802aa9b7a7
commit 3ce4406434
1 changed files with 6 additions and 3 deletions

View File

@ -869,8 +869,9 @@ impl<'gc> EditText<'gc> {
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
set_initial_value: bool, set_initial_value: bool,
) -> bool { ) -> bool {
let mut bound = false;
if let Some(var_path) = self.variable() { if let Some(var_path) = self.variable() {
let mut bound = false;
// Any previous binding should have been cleared. // Any previous binding should have been cleared.
debug_assert!(self.0.read().bound_stage_object.is_none()); debug_assert!(self.0.read().bound_stage_object.is_none());
@ -930,9 +931,11 @@ impl<'gc> EditText<'gc> {
} }
}, },
); );
}
bound bound
} else {
// No variable for this text field; success by default
true
}
} }
/// Unsets a bound display object from this text field. /// Unsets a bound display object from this text field.