From: Caisking <3449750381@qq.com> Date: Thu, 3 Oct 2024 12:38:18 +0000 (+0800) Subject: 修复训练设置Slice内存泄漏 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=3d0a8282e2c144560475611420029902e2fbb828;p=mirrors%2FFD230.git 修复训练设置Slice内存泄漏 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h index 3930b10b3..581ea6102 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h @@ -64,7 +64,6 @@ namespace OHOS TraingNomalView(TraingNomalView &&) = delete; TraingNomalView &operator=(TraingNomalView &&) = delete; - UIViewGroup *container_ = nullptr; UILabelExt *sporttitle_ = nullptr; UIButton *buttonGo_ = nullptr; UILabelButtonExt *buttonSet_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp index 47e881a78..8f4bc3a0f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp @@ -72,7 +72,10 @@ namespace OHOS /* DeInit:删除组件*/ void TraingNomalView::DeInit() { - container_->RemoveAll(); + if(container_ != nullptr) + { + container_->RemoveAll(); + } if (sporttitle_ != nullptr) { delete sporttitle_; @@ -129,7 +132,7 @@ namespace OHOS container_->SetDraggable(true); PreLoad(); - RootView::GetInstance()->Add(container_); + SetContainerView(container_); SetKeyActListener(); } @@ -156,10 +159,13 @@ namespace OHOS void TraingNomalView::OnStop() { View::OnStop(); + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } RootView::GetInstance()->RemoveAll(); - - RootView::GetInstance()->ClearOnKeyActListener(); - // FocusManager::GetInstance()->ClearFocus(); return; } }