From 3cf9620b792e83f79c4e987dda80957d06f9e114 Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Thu, 10 Oct 2024 19:03:41 +0800 Subject: [PATCH] =?utf8?q?=E7=B3=BB=E7=BB=9F=EF=BC=9A=E4=BF=AE=E5=A4=8D?= =?utf8?q?=E7=9C=81=E7=94=B5=E6=A8=A1=E5=BC=8F=E5=86=85=E5=AD=98=E6=B3=84?= =?utf8?q?=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/saveele/include/SaveBatView.h | 1 - .../nativeui/saveele/src/SaveBatView.cpp | 89 +++++++++++++++++-- .../nativeui/saveele/src/SaveEleView.cpp | 33 ++++++- 3 files changed, 112 insertions(+), 11 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/saveele/include/SaveBatView.h b/code/sdk/application/wearable/fd230app/nativeui/saveele/include/SaveBatView.h index 668f09ceb..78270fb32 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/saveele/include/SaveBatView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/saveele/include/SaveBatView.h @@ -132,7 +132,6 @@ namespace OHOS Animator *CountdownBackAnimator_ = nullptr; UICanvasExt *canvas_ = nullptr; UILabelButton *restart_ = nullptr; - UIViewGroup *container_ = nullptr; UILabel *label_ = nullptr; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveBatView.cpp b/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveBatView.cpp index f68b2e4e1..7cad67055 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveBatView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveBatView.cpp @@ -322,15 +322,90 @@ namespace OHOS g_pSaveBatView = this; } - SaveBatView::~SaveBatView() - { - /*关闭省电模式*/ - uapi_exit_power_saving_mode(); - UIViewGroup *tmpGroup = dynamic_cast(container_); - UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); + SaveBatView::~SaveBatView() + { + /* 关闭省电模式 */ + uapi_exit_power_saving_mode(); - g_pSaveBatView = nullptr; + // UIViewGroup *tmpGroup = dynamic_cast(container_); + // UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); + + // 释放所有动态分配的成员变量 + if (timelabel) { + delete timelabel; + timelabel = nullptr; + } + if (datelabel) { + delete datelabel; + datelabel = nullptr; + } + if (batterylabel) { + delete batterylabel; + batterylabel = nullptr; + } + if (batteryprogress) { + delete batteryprogress; + batteryprogress = nullptr; + } + if (batteryiamge) { + delete batteryiamge; + batteryiamge = nullptr; + } + if (button_exit) { + delete button_exit; + button_exit = nullptr; + } + + // 退出界面的成员变量 + if (curren_label) { + delete curren_label; + curren_label = nullptr; + } + if (countlabel) { + delete countlabel; + countlabel = nullptr; + } + if (wathchiamge) { + delete wathchiamge; + wathchiamge = nullptr; + } + if (backprogress) { + delete backprogress; + backprogress = nullptr; + } + + // 测试相关的成员变量 + if (CountdownBackAnimator_) { + CountdownBackAnimator_->Stop(); + } + if (callBack_) { + delete callBack_; + callBack_ = nullptr; + } + + delete CountdownBackAnimator_; + CountdownBackAnimator_ = nullptr; + + if (canvas_) { + delete canvas_; + canvas_ = nullptr; + } + if (restart_) { + delete restart_; + restart_ = nullptr; + } + if (container_) { + delete container_; + container_ = nullptr; + } + if (label_) { + delete label_; + label_ = nullptr; + } + + // 将全局指针设为 nullptr + g_pSaveBatView = nullptr; } SaveBatView *SaveBatView::GetInstance() diff --git a/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveEleView.cpp b/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveEleView.cpp index 24a8a2c17..39d532df2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveEleView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveEleView.cpp @@ -30,8 +30,35 @@ static constexpr char *butokImgPath = "/user/res/Save_Ele/Save_Right.bin"; SaveEleView::SaveEleView() { g_pSaveEleView = this; } SaveEleView::~SaveEleView() { - UIViewGroup *tmpGroup = dynamic_cast(container_); - UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); + + // UIViewGroup *tmpGroup = dynamic_cast(container_); + // UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); + + if (labeltitle) { + delete labeltitle; + labeltitle = nullptr; + } + if (labelnote) { + delete labelnote; + labelnote = nullptr; + } + if (labelkown) { + delete labelkown; + labelkown = nullptr; + } + if (iamgeicon) { + delete iamgeicon; + iamgeicon = nullptr; + } + if (buttonno) { + delete buttonno; + buttonno = nullptr; + } + if (buttonok) { + delete buttonok; + buttonok = nullptr; + } + g_pSaveEleView = nullptr; } @@ -46,7 +73,7 @@ void SaveEleView::InitView() { /*初始化label*/ InitRollLabel(labeltitle, 83, 50, 300, 35, "labletitle", STR_POWER_SAVE_MODE, - DEFAULT_VECTOR_FONT_FILENAME, 30); + DEFAULT_VECTOR_FONT_FILENAME, 30); InitLabelExt(labelnote, 53, 217, 360, 200, "labletitle", STR_SAVENOTE, DEFAULT_VECTOR_FONT_FILENAME, 30); InitLabelExt(labelkown, 53, 385, 360, 100, "labelrecord", STR_SAVEBACK, -- 2.17.1