From 0aa37307d94dea6bb2e8ed4684c6f2a081fb92f6 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Tue, 8 Oct 2024 18:59:42 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9NativeWindow=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E7=9A=84=E7=A8=B3=E5=AE=9A=E6=80=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- shell/platform/ohos/ohos_xcomponent_adapter.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/shell/platform/ohos/ohos_xcomponent_adapter.cpp b/shell/platform/ohos/ohos_xcomponent_adapter.cpp index 4d49b0c753..12c633ec66 100644 --- a/shell/platform/ohos/ohos_xcomponent_adapter.cpp +++ b/shell/platform/ohos/ohos_xcomponent_adapter.cpp @@ -330,9 +330,13 @@ void XComponentBase::OnSurfaceCreated(OH_NativeXComponent* component, (int)height_); ret = SetNativeWindowOpt((OHNativeWindow*)window, width_, height_); if (ret) { - LOGD("SetNativeWindowOpt failed:%{public}d", ret); + LOGE("SetNativeWindowOpt failed:%{public}d", ret); } if (isEngineAttached_) { + ret = OH_NativeWindow_NativeObjectReference(window); + if (ret) { + LOGE("NativeObjectReference failed:%{public}d", ret); + } PlatformViewOHOSNapi::SurfaceCreated(std::stoll(shellholderId_), window); } else { LOGE("OnSurfaceCreated XComponentBase is not attached"); @@ -362,8 +366,12 @@ void XComponentBase::OnSurfaceDestroyed(OH_NativeXComponent* component, LOGD("XComponentManger::OnSurfaceDestroyed"); if (isEngineAttached_) { PlatformViewOHOSNapi::SurfaceDestroyed(std::stoll(shellholderId_)); + int32_t ret = OH_NativeWindow_NativeObjectUnreference(window); + if (ret) { + LOGE("NativeObjectReference failed:%{public}d", ret); + } } else { - LOGE("OnSurfaceCreated OnSurfaceDestroyed is not attached"); + LOGE("XComponentManger::OnSurfaceDestroyed XComponentBase is not attached"); } } -- Gitee From ca0289c1c054f46c044a2897e36738ef422b7da5 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Tue, 8 Oct 2024 21:31:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- shell/platform/ohos/ohos_xcomponent_adapter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/ohos/ohos_xcomponent_adapter.cpp b/shell/platform/ohos/ohos_xcomponent_adapter.cpp index 12c633ec66..d6b8f9446d 100644 --- a/shell/platform/ohos/ohos_xcomponent_adapter.cpp +++ b/shell/platform/ohos/ohos_xcomponent_adapter.cpp @@ -368,7 +368,7 @@ void XComponentBase::OnSurfaceDestroyed(OH_NativeXComponent* component, PlatformViewOHOSNapi::SurfaceDestroyed(std::stoll(shellholderId_)); int32_t ret = OH_NativeWindow_NativeObjectUnreference(window); if (ret) { - LOGE("NativeObjectReference failed:%{public}d", ret); + LOGE("NativeObjectUnreference failed:%{public}d", ret); } } else { LOGE("XComponentManger::OnSurfaceDestroyed XComponentBase is not attached"); -- Gitee