From d529baf3aec43466cd32a7cf842b61e8c62f6851 Mon Sep 17 00:00:00 2001 From: wwyang <137208408@qq.com> Date: Sun, 12 Jan 2025 11:24:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=A4=9A=E5=AE=9E?= =?UTF-8?q?=E4=BE=8B=E5=9C=BA=E6=99=AF=E5=A4=96=E6=8E=A5=E7=BA=B9=E7=90=86?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=BF=94=E5=9B=9E=E7=A9=BA=E7=99=BD=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wwyang <137208408@qq.com> --- .../ets/plugin/platform/PlatformViewsController.ets | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets index 45c4177ae2..5b20438084 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets @@ -163,7 +163,9 @@ export default class PlatformViewsController implements PlatformViewsAccessibili this.viewIdWithNodeController.delete(viewId); if (this.flutterView) { let index = this.flutterView.getDVModel().children.indexOf(viewWrapper.getDvModel()!); - this.flutterView.getDVModel().children.splice(index, 1); + if (index > -1) { + this.flutterView.getDVModel().children.splice(index, 1); + } } this.viewWrappers.delete(viewId); } @@ -385,9 +387,6 @@ export default class PlatformViewsController implements PlatformViewsAccessibili public attachToView(newFlutterView : FlutterView) { this.flutterView = newFlutterView; - for (let wrapper of this.viewWrappers.values()) { - this.flutterView?.getDVModel().children.push(wrapper.getDvModel()!); - } for (let mutator of this.platformViewParent.values()) { this.flutterView?.getDVModel().children.push(mutator.getDvModel()!); } @@ -397,9 +396,6 @@ export default class PlatformViewsController implements PlatformViewsAccessibili } public detachFromView(): void { - for (let index = 0; index < this.viewWrappers.size; index++) { - this.flutterView?.getDVModel().children.pop(); - } for (let index = 0; index < this.platformViewParent.size; index++) { this.flutterView?.getDVModel().children.pop(); } -- Gitee From 46037ad7aa03f21cacd1406f7576c3c65b3e5e86 Mon Sep 17 00:00:00 2001 From: wwyang <137208408@qq.com> Date: Tue, 14 Jan 2025 19:55:41 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E5=87=8F=E5=B0=91if=E5=B5=8C=E5=A5=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wwyang <137208408@qq.com> --- .../platform/PlatformViewsController.ets | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets index 5b20438084..a89b0df74f 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets @@ -156,19 +156,18 @@ export default class PlatformViewsController implements PlatformViewsAccessibili this.textureRegistry!.unregisterTexture(textureId); } + this.viewIdWithNodeController.get(viewId)?.removeBuilderNode() + this.viewIdWithNodeController.get(viewId)?.disposeFrameNode() + this.viewIdWithNodeController.delete(viewId); + let viewWrapper: PlatformViewWrapper | null = this.viewWrappers.get(viewId) || null; - if (viewWrapper != null) { - this.viewIdWithNodeController.get(viewId)?.removeBuilderNode() - this.viewIdWithNodeController.get(viewId)?.disposeFrameNode() - this.viewIdWithNodeController.delete(viewId); - if (this.flutterView) { - let index = this.flutterView.getDVModel().children.indexOf(viewWrapper.getDvModel()!); - if (index > -1) { - this.flutterView.getDVModel().children.splice(index, 1); - } + if (viewWrapper != null && this.flutterView) { + let index = this.flutterView.getDVModel().children.indexOf(viewWrapper.getDvModel()!); + if (index > -1) { + this.flutterView.getDVModel().children.splice(index, 1); } - this.viewWrappers.delete(viewId); } + this.viewWrappers.delete(viewId); try { platformView.dispose(); -- Gitee