From bb8469a283366ed01388497390a686e26b06745c Mon Sep 17 00:00:00 2001 From: hanlin15 Date: Tue, 1 Jul 2025 21:32:32 +0800 Subject: [PATCH] fix:RegisterDeathRecipient Signed-off-by: hanlin15 Change-Id: I106bbbeb4bed72dbab838ae3178ecb274d5dce2e --- ipc/native/src/taihe/inc/taihe_remote_proxy.h | 8 ++++---- ipc/native/src/taihe/src/ohos.rpc.rpc.impl.cpp | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ipc/native/src/taihe/inc/taihe_remote_proxy.h b/ipc/native/src/taihe/inc/taihe_remote_proxy.h index af0b7316..9ec46e09 100644 --- a/ipc/native/src/taihe/inc/taihe_remote_proxy.h +++ b/ipc/native/src/taihe/inc/taihe_remote_proxy.h @@ -19,10 +19,10 @@ #include "ohos.rpc.rpc.proj.hpp" #include "ohos.rpc.rpc.impl.hpp" #include "taihe/runtime.hpp" -#include "taihe/map.hpp" #include "stdexcept" #include +#include #include #include #include @@ -40,9 +40,9 @@ public: ::ohos::rpc::rpc::RequestResult SendMessageRequestSync(int32_t code, ::ohos::rpc::rpc::weak::MessageSequence data, ::ohos::rpc::rpc::weak::MessageSequence reply, ::ohos::rpc::rpc::weak::MessageOption options); - void RegisterDeathRecipient(::ohos::rpc::rpc::weak::DeathRecipient recipient, int32_t flags); + void RegisterDeathRecipient(::ohos::rpc::rpc::DeathRecipient recipient, int32_t flags); - void UnregisterDeathRecipient(::ohos::rpc::rpc::weak::DeathRecipient recipient, int32_t flags); + void UnregisterDeathRecipient(::ohos::rpc::rpc::DeathRecipient recipient, int32_t flags); ::taihe::string GetDescriptor(); @@ -58,7 +58,7 @@ private: OHOS::sptr cachedObject_; std::optional<::ohos::rpc::rpc::RemoteProxy> jsObjRef_; std::optional<::ohos::rpc::rpc::IRemoteBroker> jsLocalInterface_; - ::taihe::map<::ohos::rpc::rpc::DeathRecipient, OHOS::sptr> deathRecipientMap_; + std::map<::ohos::rpc::rpc::DeathRecipient*, OHOS::sptr> deathRecipientMap_; }; } // namespace diff --git a/ipc/native/src/taihe/src/ohos.rpc.rpc.impl.cpp b/ipc/native/src/taihe/src/ohos.rpc.rpc.impl.cpp index a8bf01f5..86c6d3ec 100644 --- a/ipc/native/src/taihe/src/ohos.rpc.rpc.impl.cpp +++ b/ipc/native/src/taihe/src/ohos.rpc.rpc.impl.cpp @@ -234,7 +234,7 @@ RemoteProxyImpl::RemoteProxyImpl(uintptr_t nativePtr) return { ret, code, data, reply }; } -void RemoteProxyImpl::RegisterDeathRecipient(::ohos::rpc::rpc::weak::DeathRecipient recipient, int32_t flags) +void RemoteProxyImpl::RegisterDeathRecipient(::ohos::rpc::rpc::DeathRecipient recipient, int32_t flags) { OHOS::sptr nativeDeathRecipient = new (std::nothrow) DeathRecipientImpl(recipient); if (!cachedObject_->AddDeathRecipient(nativeDeathRecipient)) { @@ -242,17 +242,17 @@ void RemoteProxyImpl::RegisterDeathRecipient(::ohos::rpc::rpc::weak::DeathRecipi return; } - deathRecipientMap_.emplace(recipient, nativeDeathRecipient); + deathRecipientMap_.emplace(&recipient, nativeDeathRecipient); } -void RemoteProxyImpl::UnregisterDeathRecipient(::ohos::rpc::rpc::weak::DeathRecipient recipient, int32_t flags) +void RemoteProxyImpl::UnregisterDeathRecipient(::ohos::rpc::rpc::DeathRecipient recipient, int32_t flags) { - auto* recipientImpl = deathRecipientMap_.find_item(recipient); - if (recipientImpl != nullptr) { - if (!cachedObject_->RemoveDeathRecipient(recipientImpl->second)) { + auto it = deathRecipientMap_.find(&recipient); + if (it != deathRecipientMap_.end()) { + if (!cachedObject_->RemoveDeathRecipient(it->second)) { ZLOGE(LOG_LABEL, "RemoveDeathRecipient failed"); } - deathRecipientMap_.erase(recipient); + deathRecipientMap_.erase(&recipient); } else { ZLOGE(LOG_LABEL, "DeathRecipient not found"); } -- Gitee