From 79d78cb28b114f8846acfbbd460959f5c8c6a906 Mon Sep 17 00:00:00 2001 From: pang-wenbin2 Date: Thu, 24 Feb 2022 03:56:06 -0800 Subject: [PATCH 1/2] add file --- ext/profile/include/device_profile_adapter.h | 3 ++- ext/profile/src/device_profile_adapter.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/profile/include/device_profile_adapter.h b/ext/profile/include/device_profile_adapter.h index 3703a619a..0155daae8 100644 --- a/ext/profile/include/device_profile_adapter.h +++ b/ext/profile/include/device_profile_adapter.h @@ -24,7 +24,8 @@ namespace OHOS { namespace DistributedHardware { -class DeviceProfileAdapter : public IProfileAdapter, public IProfileConnectorCallback { +class DeviceProfileAdapter : public IProfileAdapter, public IProfileConnectorCallback, //{ + public std::enable_shared_from_this { public: DeviceProfileAdapter(); ~DeviceProfileAdapter(); diff --git a/ext/profile/src/device_profile_adapter.cpp b/ext/profile/src/device_profile_adapter.cpp index 5d6165a01..697cf5a32 100644 --- a/ext/profile/src/device_profile_adapter.cpp +++ b/ext/profile/src/device_profile_adapter.cpp @@ -36,7 +36,8 @@ int32_t DeviceProfileAdapter::RegisterProfileListener(const std::string &pkgName { LOGI("DeviceProfileAdapter::RegisterProfileListener"); deviceProfileAdapterCallback_ = callback; - profileConnector_->RegisterProfileCallback(pkgName, deviceId, std::shared_ptr(this)); + //profileConnector_->RegisterProfileCallback(pkgName, deviceId, std::shared_ptr(this)); + profileConnector_->RegisterProfileCallback(pkgName, deviceId, shared_from_this()); return DM_OK; } -- Gitee From a41795360f9ec828450fa8ee5775b03d66cd1c19 Mon Sep 17 00:00:00 2001 From: pang-wenbin2 Date: Thu, 24 Feb 2022 04:52:13 -0800 Subject: [PATCH 2/2] test file --- ext/profile/src/device_profile_adapter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/profile/src/device_profile_adapter.cpp b/ext/profile/src/device_profile_adapter.cpp index 697cf5a32..f4df2c8ab 100644 --- a/ext/profile/src/device_profile_adapter.cpp +++ b/ext/profile/src/device_profile_adapter.cpp @@ -36,7 +36,7 @@ int32_t DeviceProfileAdapter::RegisterProfileListener(const std::string &pkgName { LOGI("DeviceProfileAdapter::RegisterProfileListener"); deviceProfileAdapterCallback_ = callback; - //profileConnector_->RegisterProfileCallback(pkgName, deviceId, std::shared_ptr(this)); + //profileConnector_->RegisterProfileCallback(pkgName, deviceId, std::shared_ptr(this)) profileConnector_->RegisterProfileCallback(pkgName, deviceId, shared_from_this()); return DM_OK; } -- Gitee