From 5151f91db0b54754ba4980fc9608f3190cc13efa Mon Sep 17 00:00:00 2001 From: wangyikai Date: Thu, 11 Jul 2024 21:25:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A3=B8=E6=8C=87=E9=92=88=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BAwptr,=20=E5=A2=9E=E5=8A=A0=E6=9E=90=E6=9E=84=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E6=97=A5=E5=BF=97=E4=BB=A5=E5=AE=9A=E4=BD=8Dstub?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=9E=90=E6=9E=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyikai --- adapter/uhdf2/hdi/src/object_collector.cpp | 4 ++-- .../tools/hdi-gen/codegen/cpp_service_stub_code_emitter.cpp | 1 + interfaces/inner_api/hdi/object_collector.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/adapter/uhdf2/hdi/src/object_collector.cpp b/adapter/uhdf2/hdi/src/object_collector.cpp index 8ddcba88f..ac6bee61b 100644 --- a/adapter/uhdf2/hdi/src/object_collector.cpp +++ b/adapter/uhdf2/hdi/src/object_collector.cpp @@ -82,10 +82,10 @@ RETRY: OsalMSleep(1); goto RETRY; } - return it->second; + return it->second.GetRefPtr(); } sptr object = NewObjectLocked(interface, interfaceName); - interfaceObjectCollector_[interface.GetRefPtr()] = object.GetRefPtr(); + interfaceObjectCollector_[interface.GetRefPtr()] = object; return object; } diff --git a/framework/tools/hdi-gen/codegen/cpp_service_stub_code_emitter.cpp b/framework/tools/hdi-gen/codegen/cpp_service_stub_code_emitter.cpp index 257a4335f..bd034723f 100644 --- a/framework/tools/hdi-gen/codegen/cpp_service_stub_code_emitter.cpp +++ b/framework/tools/hdi-gen/codegen/cpp_service_stub_code_emitter.cpp @@ -330,6 +330,7 @@ void CppServiceStubCodeEmitter::EmitStubConstructorImpl(StringBuilder &sb, const sb.Append(prefix).AppendFormat( "%s::~%s()\n", EmitDefinitionByInterface(interface_, stubName_).c_str(), stubName_.c_str()); sb.Append(prefix).Append("{\n"); + sb.Append(prefix + TAB).Append("HDF_LOGI(\"%{public}s enter\", __func__);\n"); sb.Append(prefix + TAB).Append("ObjectCollector::GetInstance().RemoveObject(impl_);\n"); sb.Append(prefix).Append("}\n"); } diff --git a/interfaces/inner_api/hdi/object_collector.h b/interfaces/inner_api/hdi/object_collector.h index 653b69b10..a78a4317e 100644 --- a/interfaces/inner_api/hdi/object_collector.h +++ b/interfaces/inner_api/hdi/object_collector.h @@ -79,7 +79,7 @@ private: /** Define the mapping between the interface name and the constructor. */ std::map constructorMapper_; /** Define the mapping between the interface implementation and the object. */ - std::map interfaceObjectCollector_; + std::map> interfaceObjectCollector_; /** Define a mutex to support concurrent access to the ObjectCollector. */ std::mutex mutex_; }; -- Gitee