解决GPS产测页面内存泄漏问题 3091/2 3091/head
authorluozheng <1732036298@qq.com>
Thu, 15 Jan 2026 10:22:18 +0000 (18:22 +0800)
committerluozheng <1732036298@qq.com>
Thu, 15 Jan 2026 10:22:18 +0000 (18:22 +0800)
code/sdk/zhihui/UI/producttest/src/testGPS.cpp

index 98dc41e..6268510 100644 (file)
@@ -33,18 +33,33 @@ namespace OHOS
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "testGPSView::~testGPSView");
         ClearAll();
-        //g_pSystemAboutTheWatchView = nullptr;
+        g_pSystemAboutTheWatchView = nullptr;
     }
 
     testGPSView *testGPSView::GetInstance()
     {
-
         return g_pSystemAboutTheWatchView;
     }
     static osTimerId_t  GPS_TEST_timer=NULL;
 
     void testGPSView::ClearAll()
     {
+        // 清理主容器
+        if(mainContainer)
+        {
+            mainContainer->RemoveAll();
+            delete mainContainer;
+            mainContainer=nullptr;
+        }
+
+        // 清理滚动内容区域
+        if(contentScrollView)
+        {
+            contentScrollView->RemoveAll();
+            delete contentScrollView;
+            contentScrollView=nullptr;
+        }
+
         if (GPS_TEST_timer != NULL) {
             osTimerStop(GPS_TEST_timer);
             osTimerDelete(GPS_TEST_timer);
@@ -95,21 +110,6 @@ namespace OHOS
             failtestBtn = nullptr;
         }
         
-        // 清理滚动内容区域
-        if(contentScrollView)
-        {
-            contentScrollView->RemoveAll();
-            delete contentScrollView;
-            contentScrollView=nullptr;
-        }
-        
-        // 清理主容器
-        if(mainContainer)
-        {
-            mainContainer->RemoveAll();
-            delete mainContainer;
-            mainContainer=nullptr;
-        }
     }
    
     UILabelButtonExt *testGPSView::SetTheButton_ext(ButtonConfig_ext_t &buttonconfig)