Fix NSTextField string dealloc bug

This commit is contained in:
Ryan McGrath 2021-04-14 22:47:13 -07:00
parent 8a9c45af61
commit 5f2f1f21b0
No known key found for this signature in database
GPG key ID: DA6CBD9233593DEA

View file

@ -13,7 +13,7 @@ use crate::utils::load;
/// Called when editing this text field has ended (e.g. user pressed enter). /// Called when editing this text field has ended (e.g. user pressed enter).
extern "C" fn text_did_end_editing<T: TextFieldDelegate>(this: &mut Object, _: Sel, _info: id) { extern "C" fn text_did_end_editing<T: TextFieldDelegate>(this: &mut Object, _: Sel, _info: id) {
let view = load::<T>(this, TEXTFIELD_DELEGATE_PTR); let view = load::<T>(this, TEXTFIELD_DELEGATE_PTR);
let s = NSString::from_retained(unsafe { msg_send![this, stringValue] }); let s = NSString::retain(unsafe { msg_send![this, stringValue] });
view.text_did_end_editing(s.to_str()); view.text_did_end_editing(s.to_str());
} }
@ -49,7 +49,7 @@ extern "C" fn text_should_end_editing<T: TextFieldDelegate>(
_info: id, _info: id,
) -> BOOL { ) -> BOOL {
let view = load::<T>(this, TEXTFIELD_DELEGATE_PTR); let view = load::<T>(this, TEXTFIELD_DELEGATE_PTR);
let s = NSString::from_retained(unsafe { msg_send![this, stringValue] }); let s = NSString::retain(unsafe { msg_send![this, stringValue] });
match view.text_should_end_editing(s.to_str()) { match view.text_should_end_editing(s.to_str()) {
true => YES, true => YES,
false => NO false => NO