From: luozheng <1732036298@qq.com> Date: Tue, 19 Mar 2024 13:01:55 +0000 (+0800) Subject: 天气修改 X-Git-Tag: release_V1.2.70_20241020_135402~1250^2~19^2~7 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=30064583779351ba4ac517937f82f01fef96b5ed;p=mirrors%2FFD230.git 天气修改 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h index b9c89eee0..4d96adf12 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h @@ -174,6 +174,8 @@ namespace OHOS void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, ImageAnimatorInfo *&imageAnimatorInfo, const char **imagePaths, const ImageAnimatorConfig &imageAnimatorConfig); void FreeImagePathsArray(const char **imagePaths, const int numImages); + + void DeleteImageAnimatorInfo(ImageAnimatorInfo *&imageAnimatorInfo); }; } #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp index 1a73f16f7..4bba51e37 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp @@ -222,4 +222,16 @@ namespace OHOS } } + void ImageAnimator::DeleteImageAnimatorInfo(ImageAnimatorInfo *&imageAnimatorInfo) + { + if (imageAnimatorInfo != nullptr) + { + // 由于 imageAnimatorInfo 是一个数组,我们需要使用 delete[] 来删除它 + delete[] imageAnimatorInfo; + + // 重置指针防止悬空指针 + imageAnimatorInfo = nullptr; + } + } + } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherControlView.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherControlView.cpp index f5311c9fc..90743448a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherControlView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherControlView.cpp @@ -32,7 +32,7 @@ namespace OHOS bool WeatherControlView::InitView(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherControlView::InitView()"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WeatherControlView::InitView"); mainWeatherView = new MainWeatherView(); if (mainWeatherView == nullptr) { @@ -53,12 +53,12 @@ namespace OHOS } weatherSwipView->SetOnSwipeListener(weatherOnSwipeListener); Add(weatherSwipView); - viewiInitStatus = true; return true; } void WeatherControlView::PreLoad(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WeatherControlView::PreLoad"); if (!viewiInitStatus) { InitView(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherReportView.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherReportView.cpp index f8c449e81..80cdec067 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherReportView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherReportView.cpp @@ -83,19 +83,17 @@ namespace OHOS if (p_ImageAnimator != nullptr) { p_ImageAnimator->FreeImagePathsArray(UVPathsArray, UV_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + p_ImageAnimator->DeleteImageAnimatorInfo(UVimageAnimatorInfo); + p_ImageAnimator->FreeImagePathsArray(WindSpeedPathsArray, WINDSPEED_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + p_ImageAnimator->DeleteImageAnimatorInfo(WindSpeedimageAnimatorInfo); + p_ImageAnimator->FreeImagePathsArray(HumidityPathsArray, HUMIDITY_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + p_ImageAnimator->DeleteImageAnimatorInfo(HumidityimageAnimatorInfo); delete p_ImageAnimator; p_ImageAnimator = nullptr; } - - delete UVimageAnimatorInfo; - UVimageAnimatorInfo = nullptr; - delete WindSpeedimageAnimatorInfo; - WindSpeedimageAnimatorInfo = nullptr; - delete HumidityimageAnimatorInfo; - HumidityimageAnimatorInfo = nullptr; } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherView.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherView.cpp index b5e576308..f7d4721e2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherView.cpp @@ -44,6 +44,11 @@ namespace OHOS if (viewInitStatus == true) { RemoveAll(); + if (showWeatherImage != nullptr) + { + delete showWeatherImage; + showWeatherImage = nullptr; + } if (showCurrentTimeLabel != nullptr) { delete showCurrentTimeLabel; @@ -54,11 +59,6 @@ namespace OHOS delete showTemperatureLabel; showTemperatureLabel = nullptr; } - if (showWeatherImage != nullptr) - { - delete showWeatherImage; - showWeatherImage = nullptr; - } if (showWeatherDescriptionLabel != nullptr) { delete showWeatherDescriptionLabel; @@ -83,10 +83,11 @@ namespace OHOS if (p_ImageAnimator != nullptr) { p_ImageAnimator->FreeImagePathsArray(PullUpPathsArray, PULLUP_ANIMATOR_VIEW_NUM_FRAMES); + p_ImageAnimator->DeleteImageAnimatorInfo(PullUpimageAnimatorInfo); + delete p_ImageAnimator; p_ImageAnimator = nullptr; } - delete PullUpimageAnimatorInfo; } }