mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
TextWatchListener is removed at onDetach so that no exception is thrown if android raise textChanged but we destroyed our android object in onDestroy of edit-text (#2392)
This commit is contained in:
@ -481,3 +481,16 @@ export var testMemoryLeak = function (done) {
|
|||||||
textViewTestsNative.typeTextNatively(textView, "Hello, world!");
|
textViewTestsNative.typeTextNatively(textView, "Hello, world!");
|
||||||
}, done);
|
}, done);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function test_watch_listerer_is_removed_at_onDetach() {
|
||||||
|
if (platform.isAndroid) {
|
||||||
|
helper.buildUIAndRunTest(_createTextViewFunc(), (views: Array<viewModule.View>) => {
|
||||||
|
let tv = <textViewModule.TextView>views[0];
|
||||||
|
let page = <pagesModule.Page>tv.page;
|
||||||
|
let editText = tv.android;
|
||||||
|
editText.setText("String");
|
||||||
|
page.content = null;
|
||||||
|
editText.setText("FAIL");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -107,8 +107,11 @@ export class EditableTextBase extends common.EditableTextBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public _onDetached(force?: boolean) {
|
public _onDetached(force?: boolean) {
|
||||||
this._android = undefined;
|
if (this._android && this._textWatcher) {
|
||||||
|
this._android.removeTextChangedListener(this._textWatcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._android = undefined;
|
||||||
super._onDetached(force);
|
super._onDetached(force);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user