解決蓝牙耳机界面和声音与震动界面内存泄漏问题
authorluozheng <1732036298@qq.com>
Fri, 27 Sep 2024 10:36:25 +0000 (18:36 +0800)
committerluozheng <1732036298@qq.com>
Fri, 27 Sep 2024 10:36:25 +0000 (18:36 +0800)
code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumeView.cpp
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/VibrationModeView.cpp

index 7891457..d9fd091 100644 (file)
@@ -61,6 +61,11 @@ namespace OHOS
                     delete TradionalBlueToothLabel;\r
                     TradionalBlueToothLabel = nullptr;\r
                 }\r
+                if (BluetoothServiceOptionsLabel != nullptr)\r
+                {\r
+                    delete BluetoothServiceOptionsLabel;\r
+                    BluetoothServiceOptionsLabel = nullptr;\r
+                }\r
                 if (AttentionLabel != nullptr)\r
                 {\r
                     delete AttentionLabel;\r
index b46b068..5da2cea 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com\r
  * @Date: 2024-04-19 21:03:26\r
  * @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-09-20 15:01:12\r
+ * @LastEditTime: 2024-09-27 17:45:34\r
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h\r
  */\r
 #ifndef SOUND_AND_VIBRATION_VIEW_H\r
@@ -88,14 +88,16 @@ namespace OHOS
     private:\r
         UIScrollView *SoundAndVibrationScrollView[MAX_SOUNDANDVIBRATIONVIEWID]{nullptr};\r
         UILabelExt *Title{nullptr};                         // 标题:“声音与震动”\r
-        UILabelButtonExt *SystemVolumeButton{nullptr};      // 系统音量按钮\r
-        UILabelButtonExt *CallVolumeButton{nullptr};        // 通话音量按钮\r
-        UILabelButtonExt *VibrationReminderButton{nullptr}; // 震动提醒按钮\r
-        UILabelButtonExt *SilentModeButton{nullptr};        // 静音模式按钮\r
-        UILabelExt *SystemVolumeLabel{nullptr};             // 系统音量标签\r
-        UILabelExt *CallVolumeLabel{nullptr};               // 通话音量标签\r
-        UILabelExt *VibrationReminderLabel{nullptr};        // 震动提醒标签\r
-        UILabelExt *SilentModeLabel{nullptr};               // 静音模式标签\r
+        // UILabelButtonExt *SystemVolumeButton{nullptr};      // 系统音量按钮\r
+        // UILabelButtonExt *CallVolumeButton{nullptr};        // 通话音量按钮\r
+        // UILabelButtonExt *VibrationReminderButton{nullptr}; // 震动提醒按钮\r
+        // UILabelButtonExt *SilentModeButton{nullptr};        // 静音模式按钮\r
+        // UILabelExt *SystemVolumeLabel{nullptr};             // 系统音量标签\r
+        // UILabelExt *CallVolumeLabel{nullptr};               // 通话音量标签\r
+        // UILabelExt *VibrationReminderLabel{nullptr};        // 震动提醒标签\r
+        // UILabelExt *SilentModeLabel{nullptr};               // 静音模式标签\r
+        UILabelButtonExt *buttonPointers[4]{nullptr};\r
+        UILabelExt *labelPointers[4]{nullptr};\r
         UIToggleButton *SilentModeToggleButton{nullptr};    // 静音模式切换按钮\r
         bool initViewStatus{false};\r
         UIImageView *temp{nullptr};\r
index a78d37d..7ffafeb 100644 (file)
@@ -38,26 +38,36 @@ namespace OHOS
                 delete container_;\r
                 container_ = nullptr;\r
             }\r
-\r
+            if (CallVolumeScrollView != nullptr)\r
+            {\r
+                CallVolumeScrollView = nullptr;\r
+            }\r
             delete p_SoundAndVibrationVolumeSettingView;\r
             p_SoundAndVibrationVolumeSettingView = nullptr;\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeView::ClearAll end!!");\r
         }\r
     }\r
 \r
     UIScrollView *CallVolumeView::CallVolumeViewInit(void)\r
     {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumeView::CallVolumeViewInit");\r
-        p_SoundAndVibrationVolumeSettingView = new SoundAndVibrationVolumeSettingView(CALL_VOLUME);\r
         if (p_SoundAndVibrationVolumeSettingView == nullptr)\r
         {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!");\r
-            return nullptr;\r
+            p_SoundAndVibrationVolumeSettingView = new SoundAndVibrationVolumeSettingView(CALL_VOLUME);\r
+            if (p_SoundAndVibrationVolumeSettingView == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!");\r
+                return nullptr;\r
+            }\r
         }\r
-        CallVolumeScrollView = p_SoundAndVibrationVolumeSettingView->SetUpVolumeProcess();\r
         if (CallVolumeScrollView == nullptr)\r
         {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeView::CallVolumeScrollView is nullptr!");\r
-            return nullptr;\r
+            CallVolumeScrollView = p_SoundAndVibrationVolumeSettingView->SetUpVolumeProcess();\r
+            if (CallVolumeScrollView == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeView::CallVolumeScrollView is nullptr!");\r
+                return nullptr;\r
+            }\r
         }\r
 \r
         return CallVolumeScrollView;\r
index 1b8aca0..5eaa7ba 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com\r
  * @Date: 2024-02-19 10:39:14\r
  * @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-09-20 15:12:30\r
+ * @LastEditTime: 2024-09-27 18:30:07\r
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp\r
  */\r
 #include "soundandvibration/include/SoundAndVibrationView.h"\r
@@ -49,62 +49,59 @@ namespace OHOS
 \r
     void SoundAndVibrationView::ClearAll()\r
     {\r
-        if (container_ != nullptr)\r
+        if (initViewStatus == true)\r
         {\r
-            container_->RemoveAll();\r
-            delete container_;\r
-            container_ = nullptr;\r
-        }\r
-\r
-        if (initViewStatus)\r
-        {\r
-            if (SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] != nullptr)\r
+            if (container_ != nullptr)\r
             {\r
-                SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->RemoveAll();\r
-\r
-                delete Title;\r
-                Title = nullptr;\r
-\r
-                delete SystemVolumeButton;\r
-                SystemVolumeButton = nullptr;\r
-\r
-                delete CallVolumeButton;\r
-                CallVolumeButton = nullptr;\r
-\r
-                delete VibrationReminderButton;\r
-                VibrationReminderButton = nullptr;\r
-\r
-                delete SilentModeButton;\r
-                SilentModeButton = nullptr;\r
-\r
-                delete SilentModeToggleButton;\r
-                SilentModeToggleButton = nullptr;\r
-\r
-                delete SystemVolumeLabel;\r
-                SystemVolumeLabel = nullptr;\r
-\r
-                delete CallVolumeLabel;\r
-                CallVolumeLabel = nullptr;\r
-\r
-                delete VibrationReminderLabel;\r
-                VibrationReminderLabel = nullptr;\r
-\r
-                delete SilentModeLabel;\r
-                SilentModeLabel = nullptr;\r
-\r
-                delete temp;\r
-                temp = nullptr;\r
-\r
-                delete SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW];\r
-                SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] = nullptr;\r
+                container_->RemoveAll();\r
+                if (SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] != nullptr)\r
+                {\r
+                    SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->RemoveAll();\r
+                    if (Title != nullptr)\r
+                    {\r
+                        delete Title;\r
+                        Title = nullptr;\r
+                    }\r
+                    for (int i = 0; i < 4; i++)\r
+                    {\r
+                        if (buttonPointers[i] != nullptr)\r
+                        {\r
+                            delete buttonPointers[i];\r
+                            buttonPointers[i] = nullptr;\r
+                        }\r
+                        if (labelPointers[i] != nullptr)\r
+                        {\r
+                            delete labelPointers[i];\r
+                            labelPointers[i] = nullptr;\r
+                        }\r
+                    }\r
+                    if (SilentModeToggleButton != nullptr)\r
+                    {\r
+                        delete SilentModeToggleButton;\r
+                        SilentModeToggleButton = nullptr;\r
+                    }\r
+                    if (temp != nullptr)\r
+                    {\r
+                        delete temp;\r
+                        temp = nullptr;\r
+                    }\r
+                    delete SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW];\r
+                    SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] = nullptr;\r
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::ClearAll end!!");\r
+                }\r
+                delete container_;\r
+                container_ = nullptr;\r
             }\r
         }\r
-\r
         if (vibrationModeView != nullptr)\r
         {\r
             delete vibrationModeView;\r
             vibrationModeView = nullptr;\r
         }\r
+        for (int i = SOUNDANDVIBRATIONVIEW; i < MAX_SOUNDANDVIBRATIONVIEWID; i++)\r
+        {\r
+            SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] = nullptr;\r
+        }\r
     }\r
 \r
     /// @brief 声音与震动视图"scrollView"视图初始化\r
@@ -112,11 +109,14 @@ namespace OHOS
     /// @return true 初始化成功 false 初始化失败\r
     bool SoundAndVibrationView::InitSoundAndVibrationScrollView(void)\r
     {\r
-        SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] = new UIScrollView();\r
         if (SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] == nullptr)\r
         {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new SoundAndVibrationScrollView[%d] fail!", SOUNDANDVIBRATIONVIEW);\r
-            return false;\r
+            SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] = new UIScrollView();\r
+            if (SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new SoundAndVibrationScrollView[%d] fail!", SOUNDANDVIBRATIONVIEW);\r
+                return false;\r
+            }\r
         }\r
         SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
         SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
@@ -159,11 +159,14 @@ namespace OHOS
     /// @return true 初始化成功 false 初始化失败\r
     bool SoundAndVibrationView::InitSoundAndVibrationViewTitleLabel(void)\r
     {\r
-        Title = new UILabelExt();\r
         if (Title == nullptr)\r
         {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Title new fail!");\r
-            return false;\r
+            Title = new UILabelExt();\r
+            if (Title == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Title new fail!");\r
+                return false;\r
+            }\r
         }\r
         Title->SetPosition(83, 50, 300, 35);\r
         Title->SetStyle(STYLE_TEXT_FONT, 30);\r
@@ -187,7 +190,7 @@ namespace OHOS
             {392, STR_VIBRATION_MODE},\r
             {512, STR_SILENT_MODE},\r
         };\r
-        UILabelExt *labelPointers[] = {SystemVolumeLabel, CallVolumeLabel, VibrationReminderLabel, SilentModeLabel};\r
+        // UILabelExt *labelPointers[] = {SystemVolumeLabel, CallVolumeLabel, VibrationReminderLabel, SilentModeLabel};\r
         for (int i = 0; i < sizeof(labelSetups) / sizeof(labelSetups[0]); ++i)\r
         {\r
             labelConfig = {\r
@@ -200,11 +203,14 @@ namespace OHOS
                 .textId = labelSetups[i].textId,\r
                 .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION,\r
             };\r
-            labelPointers[i] = SetUpLabel_Ext(labelConfig);\r
             if (labelPointers[i] == nullptr)\r
             {\r
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::labelPointers[%d] new fail!", i);\r
-                return false;\r
+                labelPointers[i] = SetUpLabel_Ext(labelConfig);\r
+                if (labelPointers[i] == nullptr)\r
+                {\r
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::labelPointers[%d] new fail!", i);\r
+                    return false;\r
+                }\r
             }\r
             SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(labelPointers[i]);\r
         }\r
@@ -259,7 +265,7 @@ namespace OHOS
             {480, SILENT_MODE_BUTTON, false},\r
         };\r
 \r
-        UILabelButtonExt *buttonPointers[] = {SystemVolumeButton, CallVolumeButton, VibrationReminderButton, SilentModeButton};\r
+        // UILabelButtonExt *buttonPointers[] = {SystemVolumeButton, CallVolumeButton, VibrationReminderButton, SilentModeButton};\r
 \r
         for (int i = 0; i < sizeof(buttonSetups) / sizeof(buttonSetups[0]); ++i)\r
         {\r
@@ -270,11 +276,14 @@ namespace OHOS
                 .h = 100,\r
                 .ViewId = buttonSetups[i].viewId,\r
             };\r
-            buttonPointers[i] = SetUpButton_Ext(buttonconfig, buttonSetups[i].clickEffect);\r
             if (buttonPointers[i] == nullptr)\r
             {\r
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Button[%d] new fail!", i);\r
-                return false;\r
+                buttonPointers[i] = SetUpButton_Ext(buttonconfig, buttonSetups[i].clickEffect);\r
+                if (buttonPointers[i] == nullptr)\r
+                {\r
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Button[%d] new fail!", i);\r
+                    return false;\r
+                }\r
             }\r
             SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(buttonPointers[i]);\r
         }\r
@@ -285,11 +294,14 @@ namespace OHOS
     bool SoundAndVibrationView::InitSoundAndVibrationToggleButton(void)\r
     {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::InitSoundAndVibrationToggleButton");\r
-        SilentModeToggleButton = new UIToggleButton();\r
         if (SilentModeToggleButton == nullptr)\r
         {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeToggleButton new  fail!");\r
-            return false;\r
+            SilentModeToggleButton = new UIToggleButton();\r
+            if (SilentModeToggleButton == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeToggleButton new  fail!");\r
+                return false;\r
+            }\r
         }\r
         SilentModeToggleButton->SetPosition(298, 505, 100, 50);\r
         SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
@@ -390,11 +402,14 @@ namespace OHOS
         if (SoundAndVibrationScrollView[thisView] == nullptr)\r
         {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::ChangeVibrationModeView");\r
-            vibrationModeView = new VibrationModeView();\r
             if (vibrationModeView == nullptr)\r
             {\r
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView:: new scrollView[%d] fail", thisView);\r
-                return false;\r
+                vibrationModeView = new VibrationModeView();\r
+                if (vibrationModeView == nullptr)\r
+                {\r
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView:: new scrollView[%d] fail", thisView);\r
+                    return false;\r
+                }\r
             }\r
             SoundAndVibrationScrollView[thisView] = vibrationModeView->VibrationModeViewInit();\r
             container_->Add(SoundAndVibrationScrollView[thisView]);\r
index f4254f4..cbaa815 100644 (file)
@@ -52,6 +52,7 @@ namespace OHOS
                 }
                 delete ScrollView;
                 ScrollView = nullptr;
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::ClearAll end!!");
             }
         }
     }
@@ -76,21 +77,27 @@ namespace OHOS
     UIScrollView *SoundAndVibrationVolumeSettingView::SetUpVolumeProcess(void)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::SetUpVolumeProcess");
-        ScrollView = new UIScrollView();
         if (ScrollView == nullptr)
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::ScrollView new fail");
-            return nullptr;
+            ScrollView = new UIScrollView();
+            if (ScrollView == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::ScrollView new fail");
+                return nullptr;
+            }
         }
         ScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
         ScrollView->SetDraggable(true);
         ScrollView->SetTouchable(true);
         /* ------------------------------ VolumeProcess ----------------------------- */
-        VolumeProcess = new UISlider();
         if (VolumeProcess == nullptr)
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VolumeProcess new fail");
-            return nullptr;
+            VolumeProcess = new UISlider();
+            if (VolumeProcess == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VolumeProcess new fail");
+                return nullptr;
+            }
         }
         VolumeProcess->SetSliderColor(Color::Gray(), Color::Silver());
         VolumeProcess->SetPosition(167, 77, 130, 310);
@@ -107,11 +114,14 @@ namespace OHOS
         VolumeProcess->RequestFocus();
         VolumeProcess->SetRotateFactor(1.0);
         /* ------------------------------- VolumeVetor ------------------------------ */
-        VolumeVetor = new UIImageView();
         if (VolumeVetor == nullptr)
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VolumeVetor new fail");
-            return nullptr;
+            VolumeVetor = new UIImageView();
+            if (VolumeVetor == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VolumeVetor new fail");
+                return nullptr;
+            }
         }
         VolumeVetor->SetPosition(213, 213, 40, 40);
         VolumeVetor->SetSrc(VOLUMECONTROLVECTORIMAGEPATH);
index 398f61a..f81f29a 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com\r
  * @Date: 2024-06-12 11:44:04\r
  * @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-08-26 18:56:26\r
+ * @LastEditTime: 2024-09-27 18:01:41\r
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp\r
  */\r
 #include "soundandvibration/include/SystemVolumeView.h"\r
@@ -48,26 +48,36 @@ namespace OHOS
                 delete container_;\r
                 container_ = nullptr;\r
             }\r
-\r
+            if (SystemVolumeScrollView != nullptr)\r
+            {\r
+                SystemVolumeScrollView = nullptr;\r
+            }\r
             delete p_SoundAndVibrationVolumeSettingView;\r
             p_SoundAndVibrationVolumeSettingView = nullptr;\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::ClearAll end!!");\r
         }\r
     }\r
 \r
     UIScrollView *SystemVolumeView::SystemVolumeViewInit(void)\r
     {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::SystemVolumeViewInit");\r
-        p_SoundAndVibrationVolumeSettingView = new SoundAndVibrationVolumeSettingView(SYSTEM_VOLUME);\r
         if (p_SoundAndVibrationVolumeSettingView == nullptr)\r
         {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!");\r
-            return nullptr;\r
+            p_SoundAndVibrationVolumeSettingView = new SoundAndVibrationVolumeSettingView(SYSTEM_VOLUME);\r
+            if (p_SoundAndVibrationVolumeSettingView == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!");\r
+                return nullptr;\r
+            }\r
         }\r
-        SystemVolumeScrollView = p_SoundAndVibrationVolumeSettingView->SetUpVolumeProcess();\r
         if (SystemVolumeScrollView == nullptr)\r
         {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::SystemVolumeScrollView is nullptr!");\r
-            return nullptr;\r
+            SystemVolumeScrollView = p_SoundAndVibrationVolumeSettingView->SetUpVolumeProcess();\r
+            if (SystemVolumeScrollView == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::SystemVolumeScrollView is nullptr!");\r
+                return nullptr;\r
+            }\r
         }\r
 \r
         return SystemVolumeScrollView;\r
index 4cbd6c2..7e6d001 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-04-22 14:35:22
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-24 17:49:58
+ * @LastEditTime: 2024-09-27 18:14:37
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/VibrationModeView.cpp
  */
 #include "soundandvibration/include/VibrationModeView.h"
@@ -63,6 +63,7 @@ namespace OHOS
 
             delete scrollView;
             scrollView = nullptr;
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationModeView::ClearAll end!!");
         }
     }
 
@@ -88,11 +89,14 @@ namespace OHOS
             }
             scrollView->SetOnDragListener(dragListener);
             /* -------------------------------------------------------------------------- */
-            Title = new UILabelExt();
             if (Title == nullptr)
             {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationModeView::Title is nullptr!");
-                return nullptr;
+                Title = new UILabelExt();
+                if (Title == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationModeView::Title is nullptr!");
+                    return nullptr;
+                }
             }
             Title->SetPosition(93, 50, 280, 40);
             Title->SetStyle(STYLE_TEXT_FONT, 30);
@@ -104,11 +108,14 @@ namespace OHOS
             Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
             scrollView->Add(Title);
             /* -------------------------------------------------------------------------- */
-            VibrationModePicker = new UIPicker();
             if (VibrationModePicker == nullptr)
             {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationModeView::VibrationModePicker is nullptr!");
-                return nullptr;
+                VibrationModePicker = new UIPicker();
+                if (VibrationModePicker == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationModeView::VibrationModePicker is nullptr!");
+                    return nullptr;
+                }
             }
             VibrationModePicker->SetPosition(43, 110, 380, 240);
             VibrationModePicker->SetViewId("VibrationModePicker");
@@ -162,11 +169,14 @@ namespace OHOS
             VibrationModePicker->SetSelected(ConfigModel::GetInstance()->GetVibrationReminder());
             scrollView->Add(VibrationModePicker);
             /* -------------------------------------------------------------------------- */
-            VibrationModeLabelButton = new UILabelButtonExt();
             if (VibrationModeLabelButton == nullptr)
             {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationModeView::VibrationModeLabelButton is nullptr!");
-                return nullptr;
+                VibrationModeLabelButton = new UILabelButtonExt();
+                if (VibrationModeLabelButton == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationModeView::VibrationModeLabelButton is nullptr!");
+                    return nullptr;
+                }
             }
             VibrationModeLabelButton->SetPosition(0, 366, 466, 100);
             VibrationModeLabelButton->SetImageSrc(PNG_BUTTON_466x100_IMAGE, PNG_BUTTON_466x100_IMAGE);