From: Caisking <3449750381@qq.com> Date: Fri, 9 Aug 2024 10:01:22 +0000 (+0800) Subject: 优化组件初始化函数 X-Git-Tag: release_V1.2.70_20241020_135402~679^2~26 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=629aca35a0b9bd88880277a8f68a674b3b682a31;p=mirrors%2FFD230.git 优化组件初始化函数 --- diff --git a/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp b/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp index 53429260b..bc3df8d6f 100644 --- a/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp +++ b/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp @@ -170,11 +170,14 @@ namespace OHOS bool InitButtonExt(UILabelButtonExt *&button, int left, int top, int width, int height, const char *viewId, UIResourceTextId id, int fontSize) { // 创建新按钮(如果当前按钮为空) - button = new UILabelButtonExt(); if (button == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButtonExt is error"); - return false; // 内存分配失败,返回false + button = new UILabelButtonExt(); + if (button == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButtonExt is error"); + return false; // 内存分配失败,返回false + } } button->SetPosition(left, top); button->Resize(width, height);