From: Caisking <3449750381@qq.com> Date: Sat, 31 Aug 2024 07:24:12 +0000 (+0800) Subject: 修复遥控拍照动画的内存泄漏 X-Git-Tag: release_V1.2.70_20241020_135402~545^2~7 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=126956c326e31d8596f820a75ca7a10fc2aa0e1e;p=mirrors%2FFD230.git 修复遥控拍照动画的内存泄漏 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/takephotos/include/TakephotosView.h b/code/sdk/application/wearable/fd230app/nativeui/takephotos/include/TakephotosView.h index 46717ada8..319e10a8b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/takephotos/include/TakephotosView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/takephotos/include/TakephotosView.h @@ -86,8 +86,11 @@ namespace OHOS std::string creambasePath; const char **creamimagePaths; + ImageAnimatorInfo *creamimageAnimatorInfo{nullptr}; + std::string smilebasePath; const char **smileimagePaths; + ImageAnimatorInfo *smileimageAnimatorInfo{nullptr}; }; } // namespace OHOS #endif // Takephotos_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosView.cpp b/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosView.cpp index 76f08718b..f9ed31a7e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosView.cpp @@ -29,11 +29,12 @@ namespace OHOS TakephotosView::~TakephotosView() { // DeInit(); - creamAnimator->Stop(); smileAnimator->Stop(); FreeImagePathsArray(creamimagePaths, 50); FreeImagePathsArray(smileimagePaths, 27); + ReleaseImageAnimatorSource(creamimageAnimatorInfo,50); + ReleaseImageAnimatorSource(smileimageAnimatorInfo,27); UIViewGroup *tmpGroup = dynamic_cast(container_); UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); @@ -147,7 +148,7 @@ namespace OHOS // 初始化图片数组以及动画 creambasePath = "/user/res/takephotos/cream/"; creamimagePaths = CreateImagePathsArray(creambasePath.c_str(), 50); - InitImageAnimatorSource(creamAnimator, creamimagePaths, 50, 163, 103, 140, 140, "imageAnimator", 100); + InitImageAnimatorSource(creamAnimator, creamimageAnimatorInfo, creamimagePaths, 50, 163, 103, 140, 140, "imageAnimator", 100); creamView->Add(creamAnimator); creamView->Add(labeltitle_); @@ -198,7 +199,7 @@ namespace OHOS // 初始化图片数组以及动画 {修改为统一动画} smilebasePath = "/user/res/takephotos/cream/"; smileimagePaths = CreateImagePathsArray(smilebasePath.c_str(), 27); - InitImageAnimatorSource(smileAnimator, smileimagePaths, 27, 163, 140, 140, 140, "imageAnimator", 100); + InitImageAnimatorSource(smileAnimator, smileimageAnimatorInfo, smileimagePaths, 27, 163, 140, 140, 140, "imageAnimator", 100); takeView->Add(smileAnimator); takeView->Add(labeltake_);