@@ -87,29 +87,28 @@ int Widget_SetAttributeEx(LCUI_Widget w, const char *name, void *value,
87
87
int Widget_SetAttribute (LCUI_Widget w , const char * name , const char * value )
88
88
{
89
89
int ret ;
90
- char * value_str ;
90
+ char * value_str = NULL ;
91
91
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
- }
100
92
if (value ) {
101
93
value_str = strdup2 (value );
102
94
if (!value_str ) {
103
95
return - ENOMEM ;
104
96
}
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
+ }
105
104
ret = Widget_SetAttributeEx (w , name , value_str ,
106
105
LCUI_STYPE_STRING , free );
107
106
} else {
108
107
ret = Widget_SetAttributeEx (w , name , NULL , LCUI_STYPE_NONE ,
109
108
NULL );
110
109
}
111
110
if (w -> proto && w -> proto -> setattr ) {
112
- w -> proto -> setattr (w , name , value );
111
+ w -> proto -> setattr (w , name , value_str );
113
112
}
114
113
return ret ;
115
114
}
0 commit comments