diff --git a/ipc/native/src/jni/source/ohos_rpc_remote_object.cpp b/ipc/native/src/jni/source/ohos_rpc_remote_object.cpp index fbd26aa832d80a2f46f36a1bf6d3e3056d30dcea..2ece05d24c8141b4d590a4c22069ca2a57099552 100644 --- a/ipc/native/src/jni/source/ohos_rpc_remote_object.cpp +++ b/ipc/native/src/jni/source/ohos_rpc_remote_object.cpp @@ -96,7 +96,7 @@ public: private: std::mutex mutex_; std::u16string descriptor_; - wptr cachedObject_; + sptr cachedObject_; }; /* @@ -250,7 +250,7 @@ sptr JRemoteObjectHolder::Get(jobject object) // so it will not be freed util this reference released. sptr remoteObject = nullptr; if (cachedObject_ != nullptr) { - remoteObject = cachedObject_.promote(); + remoteObject = cachedObject_; } if (remoteObject == nullptr) { diff --git a/ipc/native/src/napi_common/include/napi_remote_object_holder.h b/ipc/native/src/napi_common/include/napi_remote_object_holder.h index 9318d3eabf31c0ec1cfbcefd9eae51f0332d3da5..eb8137de9d5fcba8cd6d060e6578ca6cf8947d68 100644 --- a/ipc/native/src/napi_common/include/napi_remote_object_holder.h +++ b/ipc/native/src/napi_common/include/napi_remote_object_holder.h @@ -64,7 +64,7 @@ private: std::mutex mutex_; napi_env env_ = nullptr; std::u16string descriptor_; - wptr cachedObject_; + sptr cachedObject_; napi_ref localInterfaceRef_; int32_t attachCount_; }; diff --git a/ipc/native/src/napi_common/source/napi_remote_object_holder.cpp b/ipc/native/src/napi_common/source/napi_remote_object_holder.cpp index 3ff0487dea275132037f859fefa46861621ef76b..f13097076bed6898f44156fac3187d24d1cb8c55 100644 --- a/ipc/native/src/napi_common/source/napi_remote_object_holder.cpp +++ b/ipc/native/src/napi_common/source/napi_remote_object_holder.cpp @@ -38,7 +38,7 @@ sptr NAPIRemoteObjectHolder::Get(napi_value jsRemoteObject) // so it will not be freed util this reference released. sptr remoteObject = nullptr; if (cachedObject_ != nullptr) { - remoteObject = cachedObject_.promote(); + remoteObject = cachedObject_; } if (remoteObject == nullptr) {