修复遥控拍照动画的内存泄漏
authorCaisking <3449750381@qq.com>
Sat, 31 Aug 2024 07:24:12 +0000 (15:24 +0800)
committerCaisking <3449750381@qq.com>
Sat, 31 Aug 2024 07:24:12 +0000 (15:24 +0800)
code/sdk/application/wearable/fd230app/nativeui/takephotos/include/TakephotosView.h
code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosView.cpp

index 46717ad..319e10a 100644 (file)
@@ -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
index 76f0871..f9ed31a 100644 (file)
@@ -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<UIViewGroup *>(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_);