From: luozheng <1732036298@qq.com> Date: Sat, 5 Oct 2024 11:35:36 +0000 (+0800) Subject: 解决蓝牙耳机界面内存泄漏问题 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=ecee0300be1de2d740dc58313a4f21b17605c4e8;p=mirrors%2FFD230.git 解决蓝牙耳机界面内存泄漏问题 解决蓝牙耳机界面,如果进入搜索界面开启定时器后,按按键未关闭定时器问题 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp index f945029d2..5be4c75c0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp @@ -17,10 +17,14 @@ namespace OHOS { BluetoothDeviceCaseListAdapter::~BluetoothDeviceCaseListAdapter() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceCaseListAdapter::~BluetoothDeviceCaseListAdapter"); - UIView::OnClickListener *click = item->GetOnClickListener(); - if (click != nullptr) { - delete click; - click = nullptr; + // UIView::OnClickListener *click = item->GetOnClickListener(); + // if (click != nullptr) { + // delete click; + // click = nullptr; + // } + if (listener != nullptr) { + delete listener; + listener = nullptr; } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothPresenter.cpp index aa5f2ff2a..503217724 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothPresenter.cpp @@ -244,6 +244,15 @@ bool BluetoothPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 如果是power键就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) { + //如果是按键退出,退出时需要做一些清理工作 + BluetoothEarPhoneView *bluetoothEarPhoneView = BluetoothEarPhoneView::GetInstance(); + if(bluetoothEarPhoneView) + { + bluetoothEarPhoneView->BtAnimatorStop(); //停止搜索动画 + bluetoothEarPhoneView->StopBtDiscovery();//停止定时器 + BluetoothModel::GetInstance()->SetTagConnectView(false); //清除标志位 + BluetoothModel::GetInstance()->SetTagScanDeviceClicked(false); + } NativeAbility::GetInstance().Back(); } return true; diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/TipsConnFailMessageView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/TipsConnFailMessageView.cpp index 8d125872f..5fdfd13f9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/TipsConnFailMessageView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/TipsConnFailMessageView.cpp @@ -46,6 +46,16 @@ namespace OHOS delete tipLabel; tipLabel = nullptr; } + if (conn_fail_Label) + { + delete conn_fail_Label; + conn_fail_Label = nullptr; + } + if (bluetoothNameLabel) + { + delete bluetoothNameLabel; + bluetoothNameLabel = nullptr; + } delete group; group = nullptr; }