From 8bc96649eb6865e5609834828f3b1fb8e444caeb Mon Sep 17 00:00:00 2001 From: law Date: Sun, 10 Aug 2025 17:56:12 +0800 Subject: [PATCH] fix:modify code warning Signed-off-by: law --- core/connection/wifi_direct_cpp/data/info_container.h | 6 +++++- .../wifi_direct_cpp/event/wifi_direct_event_wrapper.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/connection/wifi_direct_cpp/data/info_container.h b/core/connection/wifi_direct_cpp/data/info_container.h index 96bb0047dc..7ecf7933fb 100644 --- a/core/connection/wifi_direct_cpp/data/info_container.h +++ b/core/connection/wifi_direct_cpp/data/info_container.h @@ -33,7 +33,11 @@ protected: T Get(Key key, const T &defaultValue) const { const auto it = values_.find(key); - return it != values_.end() ? std::any_cast(it->second) : defaultValue; + try { + return it != values_.end() ? std::any_cast(it->second) : defaultValue; + } catch (std::bad_any_cast &ignore) { + return defaultValue; + } } using KeyTypeTable = std::map; diff --git a/core/connection/wifi_direct_cpp/event/wifi_direct_event_wrapper.h b/core/connection/wifi_direct_cpp/event/wifi_direct_event_wrapper.h index 4fdaa53a5c..1b2469a782 100644 --- a/core/connection/wifi_direct_cpp/event/wifi_direct_event_wrapper.h +++ b/core/connection/wifi_direct_cpp/event/wifi_direct_event_wrapper.h @@ -23,7 +23,7 @@ struct DLL_EXPORT WifiDirectEventWrapper : public WifiDirectEventBase { Content content_; explicit WifiDirectEventWrapper(const Content &content) : content_(content) {}; - ~WifiDirectEventWrapper(){} + ~WifiDirectEventWrapper() override {} std::string getContentTypeid() override { return typeid(content_).name(); -- Gitee