From 515189dae21a956afba55bfcdf36458c87221d9d Mon Sep 17 00:00:00 2001 From: kaicui Date: Sat, 6 Sep 2025 19:19:07 +0800 Subject: [PATCH 1/2] Remove redundant methods and fix double free ref Signed-off-by: kaicui --- interfaces/innerkits/wm/window.h | 3 --- .../window_stage_ani/src/ani_window_listener.cpp | 7 +++++-- wm/include/window_extension_session_impl.h | 4 ---- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 55468f40b2..ef1cc1a0a9 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -2200,9 +2200,6 @@ public: virtual WMError NapiSetUIContentByName(const std::string& contentName, napi_env env, napi_value storage, BackupAndRestoreType type = BackupAndRestoreType::NONE, sptr token = nullptr, AppExecFwk::Ability* ability = nullptr) { return WMError::WM_OK; } - virtual WMError NapiSetUIContentByName(const std::string& contentName, ani_env* env, ani_object storage, - BackupAndRestoreType type = BackupAndRestoreType::NONE, sptr token = nullptr, - AppExecFwk::Ability* ability = nullptr) { return WMError::WM_OK; } virtual WMError AniSetUIContentByName(const std::string& contentName, ani_env* env, ani_object storage, BackupAndRestoreType type = BackupAndRestoreType::NONE, sptr token = nullptr, AppExecFwk::Ability* ability = nullptr) { return WMError::WM_OK; } diff --git a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_listener.cpp b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_listener.cpp index ccb884c947..15e73319fe 100644 --- a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_listener.cpp +++ b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_listener.cpp @@ -27,8 +27,11 @@ using namespace AbilityRuntime; AniWindowListener::~AniWindowListener() { - ani_status ret = env_->GlobalReference_Delete(aniCallback_); - TLOGI(WmsLogTag::DEFAULT, "[ANI]~AniWindowListener ret:%{public}d", static_cast(ret)); + ani_status ret = ANI_OK; + if (env_ != nullptr && aniCallback_ != nullptr) { + ret = env_->GlobalReference_Delete(aniCallback_); + } + TLOGI(WmsLogTag::DEFAULT, "[ANI]~AniWindowListener ret: %{public}u", ret); } void AniWindowListener::OnLastStrongRef(const void *) diff --git a/wm/include/window_extension_session_impl.h b/wm/include/window_extension_session_impl.h index ead7a8592a..f3f5bf1040 100644 --- a/wm/include/window_extension_session_impl.h +++ b/wm/include/window_extension_session_impl.h @@ -72,12 +72,8 @@ public: WMError NapiSetUIContent(const std::string& contentInfo, napi_env env, napi_value storage, BackupAndRestoreType type, sptr token, AppExecFwk::Ability* ability) override; - WMError NapiSetUIContent(const std::string& contentInfo, ani_env* env, ani_object storage, - BackupAndRestoreType type, sptr token, AppExecFwk::Ability* ability) override; WMError AniSetUIContent(const std::string& contentInfo, ani_env* env, ani_object storage, BackupAndRestoreType type, sptr token, AppExecFwk::Ability* ability) override; - WMError NapiSetUIContentByName(const std::string& contentName, napi_env env, napi_value storage, - BackupAndRestoreType type, sptr token, AppExecFwk::Ability* ability) override; WMError NapiSetUIContentByName(const std::string& contentName, ani_env* env, ani_object storage, BackupAndRestoreType type, sptr token, AppExecFwk::Ability* ability) override; WMError AniSetUIContentByName(const std::string& contentName, ani_env* env, ani_object storage, -- Gitee From e778e377ae430f297a713b6776535fb9c3f257dc Mon Sep 17 00:00:00 2001 From: kaicui Date: Sat, 6 Sep 2025 20:24:31 +0800 Subject: [PATCH 2/2] Fix typos Signed-off-by: kaicui --- wm/include/window_extension_session_impl.h | 2 +- wm/src/window_extension_session_impl.cpp | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/wm/include/window_extension_session_impl.h b/wm/include/window_extension_session_impl.h index f3f5bf1040..29a83d730a 100644 --- a/wm/include/window_extension_session_impl.h +++ b/wm/include/window_extension_session_impl.h @@ -74,7 +74,7 @@ public: BackupAndRestoreType type, sptr token, AppExecFwk::Ability* ability) override; WMError AniSetUIContent(const std::string& contentInfo, ani_env* env, ani_object storage, BackupAndRestoreType type, sptr token, AppExecFwk::Ability* ability) override; - WMError NapiSetUIContentByName(const std::string& contentName, ani_env* env, ani_object storage, + WMError NapiSetUIContentByName(const std::string& contentName, napi_env env, napi_value storage, BackupAndRestoreType type, sptr token, AppExecFwk::Ability* ability) override; WMError AniSetUIContentByName(const std::string& contentName, ani_env* env, ani_object storage, BackupAndRestoreType type, sptr token, AppExecFwk::Ability* ability) override; diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index 1337644318..631bf51f4e 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -705,12 +705,6 @@ WMError WindowExtensionSessionImpl::NapiSetUIContent(const std::string& contentI return SetUIContentInner(contentInfo, env, storage, token, ability, false, EnvironmentType::NAPI); } -WMError WindowExtensionSessionImpl::NapiSetUIContent(const std::string& contentInfo, ani_env* env, ani_object storage, - BackupAndRestoreType type, sptr token, AppExecFwk::Ability* ability) -{ - return SetUIContentInner(contentInfo, env, storage, token, ability, false, EnvironmentType::ANI); -} - WMError WindowExtensionSessionImpl::AniSetUIContent(const std::string& contentInfo, ani_env* env, ani_object storage, BackupAndRestoreType type, sptr token, AppExecFwk::Ability* ability) { @@ -724,13 +718,6 @@ WMError WindowExtensionSessionImpl::NapiSetUIContentByName(const std::string& co return SetUIContentInner(contentName, env, storage, token, ability, true, EnvironmentType::NAPI); } -WMError WindowExtensionSessionImpl::NapiSetUIContentByName(const std::string& contentName, ani_env* env, - ani_object storage, BackupAndRestoreType type, sptr token, AppExecFwk::Ability* ability) -{ - TLOGI(WmsLogTag::WMS_UIEXT, "name: %{public}s", contentName.c_str()); - return SetUIContentInner(contentName, env, storage, token, ability, true, EnvironmentType::ANI); -} - WMError WindowExtensionSessionImpl::AniSetUIContentByName(const std::string& contentName, ani_env* env, ani_object storage, BackupAndRestoreType type, sptr token, AppExecFwk::Ability* ability) { -- Gitee