未验证 提交 56954457 编写于 作者: A Amir Hardon 提交者: GitHub

Don't hang to a platform view's input connection after it's disposed (#9423)

Addresses the crash reported in https://github.com/flutter/flutter/issues/19718#issuecomment-504174596
上级 45ef6c8c
......@@ -237,6 +237,21 @@ public class TextInputPlugin {
return lastInputConnection;
}
/**
* Clears a platform view text input client if it is the current input target.
*
* This is called when a platform view is disposed to make sure we're not hanging to a stale input
* connection.
*/
public void clearPlatformViewClient(int platformViewId) {
if (inputTarget.type == InputTarget.Type.PLATFORM_VIEW && inputTarget.id == platformViewId) {
inputTarget = new InputTarget(InputTarget.Type.NO_TARGET, 0);
hideTextInput(mView);
mImm.restartInput(mView);
mRestartInputPending = false;
}
}
private void showTextInput(View view) {
view.requestFocus();
mImm.showSoftInput(view, 0);
......
......@@ -135,8 +135,11 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
+ viewId);
}
contextToPlatformView.remove(vdController.getView().getContext());
if (textInputPlugin != null) {
textInputPlugin.clearPlatformViewClient(viewId);
}
contextToPlatformView.remove(vdController.getView().getContext());
vdController.dispose();
vdControllers.remove(viewId);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册