@@ -87,29 +87,28 @@ int Widget_SetAttributeEx(LCUI_Widget w, const char *name, void *value,
8787int Widget_SetAttribute (LCUI_Widget w , const char * name , const char * value )
8888{
8989 int ret ;
90- char * value_str ;
90+ char * value_str = NULL ;
9191
92- if (strcmp (name , "disabled" ) == 0 ) {
93- if (!value || strcmp (value , "false" ) != 0 ) {
94- Widget_SetDisabled (w , TRUE);
95- } else {
96- Widget_SetDisabled (w , FALSE);
97- }
98- return 0 ;
99- }
10092 if (value ) {
10193 value_str = strdup2 (value );
10294 if (!value_str ) {
10395 return - ENOMEM ;
10496 }
97+ if (strcmp (name , "disabled" ) == 0 ) {
98+ if (!value || strcmp (value , "false" ) != 0 ) {
99+ Widget_SetDisabled (w , TRUE);
100+ } else {
101+ Widget_SetDisabled (w , FALSE);
102+ }
103+ }
105104 ret = Widget_SetAttributeEx (w , name , value_str ,
106105 LCUI_STYPE_STRING , free );
107106 } else {
108107 ret = Widget_SetAttributeEx (w , name , NULL , LCUI_STYPE_NONE ,
109108 NULL );
110109 }
111110 if (w -> proto && w -> proto -> setattr ) {
112- w -> proto -> setattr (w , name , value );
111+ w -> proto -> setattr (w , name , value_str );
113112 }
114113 return ret ;
115114}
0 commit comments