From 8293b25831358ecd52014217fac97f124af240d8 Mon Sep 17 00:00:00 2001 From: Caisking Date: Fri, 20 Mar 2026 14:44:43 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8D=E4=B8=BB=E7=95=8C=E9=9D=A2not?= =?utf8?q?ify=E7=9A=84=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/main/src/MainPresenterSample.cpp | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/main/src/MainPresenterSample.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/main/src/MainPresenterSample.cpp index b2bad82b1..9680dd378 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/main/src/MainPresenterSample.cpp @@ -431,6 +431,11 @@ /* --------------------------------- 主界面卡片功能 -------------------------------- */ void MainPresenterSample::Notify(void) { + if (view_ == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Notify: view_ is nullptr"); + return; + } CardId currentCardId = view_->GetHorCurrentCard(); // 从心率卡片变为其他卡片时关闭心率检测 @@ -510,8 +515,8 @@ { if (SleepCardView::GetInstance() != nullptr) { - auto sleepCardView = SleepCardView::GetInstance()->GetSleepCardView(); - if (sleepCardView->GetCurrentPage() != 0) + auto sleepCardView = SleepCardView::GetInstance()->GetSleepCardView(); + if (sleepCardView != nullptr && sleepCardView->GetCurrentPage() != 0) { sleepCardView->SetCurrentPage(0); } @@ -525,7 +530,7 @@ if(WeatherControlView::GetInstance()) { auto weatherSwipView = WeatherControlView::GetInstance()->GetWeatherSwipView(); - if (weatherSwipView->GetCurrentPage() != 0) + if (weatherSwipView != nullptr && weatherSwipView->GetCurrentPage() != 0) { weatherSwipView->SetCurrentPage(0); } @@ -537,7 +542,7 @@ if(goalControlView::GetInstance()) { auto goalSwipView = goalControlView::GetInstance()->GetGoalControlSwipView(); - if (goalSwipView->GetCurrentPage() != 0) + if (goalSwipView != nullptr && goalSwipView->GetCurrentPage() != 0) { goalSwipView->SetCurrentPage(0); } @@ -564,16 +569,34 @@ { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "view_ is nullptr"); return; + } + UIView *watchFace = view_->GetViewById(WATCH_FACE); + if (watchFace == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateWatchFace: watchFace is nullptr"); + return; } DialSetting &setting = GetDialSetting(); if (setting.dialFlag) { DialModelTime::GetInstance()->UpdateTime(); - dynamic_cast(view_->GetViewById(WATCH_FACE))->UpdateViewsByPeriodicUpdateData(); + auto dialViewGroup = dynamic_cast(watchFace); + if (dialViewGroup == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateWatchFace: DialViewGroup cast failed"); + return; + } + dialViewGroup->UpdateViewsByPeriodicUpdateData(); } else { - dynamic_cast(view_->GetViewById(WATCH_FACE))->UpdateTime(); + auto mainClockView = dynamic_cast(watchFace); + if (mainClockView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateWatchFace: MainClockView cast failed"); + return; + } + mainClockView->UpdateTime(); } } -- 2.17.1