修改心率Slice的析构
authorCaisking <3449750381@qq.com>
Fri, 27 Sep 2024 07:37:48 +0000 (15:37 +0800)
committerCaisking <3449750381@qq.com>
Fri, 27 Sep 2024 07:37:48 +0000 (15:37 +0800)
code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartChartPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartChartView.cpp

index 49219fb..730528b 100644 (file)
@@ -108,7 +108,6 @@ namespace OHOS
             return;
         }
 
-        HeartChartView::GetInstance()->UpdateShowHeart(); 
         uint64_t current_time = osKernelGetTick2ms();
         if ((startTime != 0) && (current_time - startTime >= HEART_KEEP_TIME))
         {
@@ -116,7 +115,10 @@ namespace OHOS
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果: 超时处理 HEART_KEEP_TIME: %lld", current_time - startTime);
             HeartModel::GetInstance()->SetResult(HeartResult::TIMEOUT);
             HeartModel::GetInstance()->Heart_Stop();
+            return;
         }
+
+        HeartChartView::GetInstance()->UpdateShowHeart(); 
     }
 
     // 增加按键事件
index 2f40a01..da69665 100644 (file)
@@ -161,55 +161,85 @@ HeartChartView::HeartChartView() {
 }
 HeartChartView::~HeartChartView() {
   WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartChartView::~HeartChartView");
+  if (container_)
+    container_->RemoveAll();
 
-    UIViewGroup *tmpGroup = dynamic_cast<UIViewGroup *>(container_);
-    UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup);
+  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 0
+  if (maxRateIconView_) {
+    delete maxRateIconView_;
+    maxRateIconView_ = nullptr;
+  }
+  if (minRateIconView_) {
+    delete minRateIconView_;
+    minRateIconView_ = nullptr;
+  }
+  if (chartBackgroundView_) {
+    delete chartBackgroundView_;
+    chartBackgroundView_ = nullptr;
+  }
+  if (heartIconView_) {
+    delete heartIconView_;
+    heartIconView_ = nullptr;
+  }
 
-  container_->RemoveAll();
-
-  delete displayheart_;
-  displayheart_ = nullptr;
-  delete maxheart_;
-  maxheart_ = nullptr;
-  delete minheart_;
-  minheart_ = nullptr;
-  delete uheart_;
-  uheart_ = nullptr;
-  delete lastheart_;
-  lastheart_ = nullptr;
-  delete maxheart_dynamic_;
-  maxheart_dynamic_ = nullptr;
-  delete maxheart_dynamic_3_;
-  maxheart_dynamic_3_ = nullptr;
-  delete maxheart_dynamic_2_;
-  maxheart_dynamic_2_ = nullptr;
-  delete maxheart_dynamic_1_;
-  maxheart_dynamic_1_ = nullptr;
-  delete minheart_dynamic_;
-  minheart_dynamic_ = nullptr;
-
-  delete maxRateIconView_;
-  maxRateIconView_ = nullptr;
-  delete minRateIconView_;
-  minRateIconView_ = nullptr;
-  delete chartBackgroundView_;
-  chartBackgroundView_ = nullptr;
-  delete heartIconView_;
-  heartIconView_ = nullptr;
-
-  imageAnimator->Stop();
-  delete imageAnimator;
-  imageAnimator = nullptr;
-
-  heartchart->ClearDataSerial();
-  delete heartSerial;
-  heartSerial = nullptr;
-  delete heartchart;
-  heartchart = nullptr;
-#endif
-    g_pHeartCheckView = this;
+  if (imageAnimator) {
+    imageAnimator->Stop();
+    delete imageAnimator;
+    imageAnimator = nullptr;
+  }
+
+  if (heartSerial) {
+    heartchart->ClearDataSerial();
+    delete heartSerial;
+    heartSerial = nullptr;
+  }
+
+  if (heartchart) {
+    delete heartchart;
+    heartchart = nullptr;
+  }
+
+  g_pHeartCheckView = nullptr;
 }
 HeartChartView *HeartChartView::GetInstance(void) { return g_pHeartCheckView; }