}
HeartChartView::~HeartChartView() {
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartChartView::~HeartChartView");
- if (scrollView) {
- scrollView->RemoveAll();
-
- if (displayheart_) {
- delete displayheart_;
- displayheart_ = nullptr;
- }
- if (maxheart_) {
- delete maxheart_;
- maxheart_ = nullptr;
- }
- if (minheart_) {
- delete minheart_;
- minheart_ = nullptr;
- }
- if (uheart_) {
- delete uheart_;
- uheart_ = nullptr;
- }
- if (lastheart_) {
- delete lastheart_;
- lastheart_ = nullptr;
- }
- if (maxheart_dynamic_) {
- delete maxheart_dynamic_;
- maxheart_dynamic_ = nullptr;
- }
- if (maxheart_dynamic_3_) {
- delete maxheart_dynamic_3_;
- maxheart_dynamic_3_ = nullptr;
- }
- if (maxheart_dynamic_2_) {
- delete maxheart_dynamic_2_;
- maxheart_dynamic_2_ = nullptr;
- }
- if (maxheart_dynamic_1_) {
- delete maxheart_dynamic_1_;
- maxheart_dynamic_1_ = nullptr;
- }
- if (minheart_dynamic_) {
- delete minheart_dynamic_;
- minheart_dynamic_ = nullptr;
- }
-
- if (maxRateIconView_) {
- delete maxRateIconView_;
- maxRateIconView_ = nullptr;
- }
- if (minRateIconView_) {
- delete minRateIconView_;
- minRateIconView_ = nullptr;
- }
- if (chartBackgroundView_) {
- delete chartBackgroundView_;
- chartBackgroundView_ = nullptr;
- }
- if (heartIconView_) {
- delete heartIconView_;
- heartIconView_ = nullptr;
- }
-
- if (imageAnimator) {
- imageAnimator->Stop();
- delete imageAnimator;
- imageAnimator = nullptr;
- }
-
- if (heartSerial) {
- heartchart->ClearDataSerial();
- delete heartSerial;
- heartSerial = nullptr;
- }
+ g_pHeartCheckView = nullptr; // 提前置空,防止析构期间被其他线程使用
+ if (!viewInitStatus_ || scrollView == nullptr) {
+ return;
+ }
+ scrollView->RemoveAll();
+
+ // 释放 Label
+ if (displayheart_) { delete displayheart_; displayheart_ = nullptr; }
+ if (maxheart_) { delete maxheart_; maxheart_ = nullptr; }
+ if (minheart_) { delete minheart_; minheart_ = nullptr; }
+ if (uheart_) { delete uheart_; uheart_ = nullptr; }
+ if (lastheart_) { delete lastheart_; lastheart_ = nullptr; }
+ if (maxheart_dynamic_) { delete maxheart_dynamic_; maxheart_dynamic_ = nullptr; }
+ if (maxheart_dynamic_3_) { delete maxheart_dynamic_3_; maxheart_dynamic_3_ = nullptr; }
+ if (maxheart_dynamic_2_) { delete maxheart_dynamic_2_; maxheart_dynamic_2_ = nullptr; }
+ if (maxheart_dynamic_1_) { delete maxheart_dynamic_1_; maxheart_dynamic_1_ = nullptr; }
+ if (minheart_dynamic_) { delete minheart_dynamic_; minheart_dynamic_ = nullptr; }
+
+ // 释放 ImageView
+ if (maxRateIconView_) { delete maxRateIconView_; maxRateIconView_ = nullptr; }
+ if (minRateIconView_) { delete minRateIconView_; minRateIconView_ = nullptr; }
+ if (chartBackgroundView_) { delete chartBackgroundView_; chartBackgroundView_ = nullptr; }
+ if (heartIconView_) { delete heartIconView_; heartIconView_ = nullptr; }
+
+ // 先 Stop 再释放 Animator
+ if (imageAnimator) {
+ imageAnimator->Stop();
+ delete imageAnimator;
+ imageAnimator = nullptr;
+ }
+ // Chart 与 Serial:先 ClearDataSerial 解除引用,再 delete
+ if (heartSerial) {
if (heartchart) {
- delete heartchart;
- heartchart = nullptr;
+ heartchart->ClearDataSerial();
}
-
- delete scrollView;
- scrollView = nullptr;
+ delete heartSerial;
+ heartSerial = nullptr;
+ }
+ if (heartchart) {
+ delete heartchart;
+ heartchart = nullptr;
}
- g_pHeartCheckView = nullptr;
+
+ delete scrollView;
+ scrollView = nullptr;
}
HeartChartView *HeartChartView::GetInstance(void) { return g_pHeartCheckView; }
InitChartLabel();
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartChartViewInit is ok");
+ viewInitStatus_ = true;
return true;
}
UIScrollView *HeartChartView::GetchartGroup() {