Skip to content

Commit 4b0a2ed

Browse files
committed
fix(gui): widget attribute value should always be available
1 parent c9550ac commit 4b0a2ed

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/gui/widget_attribute.c

+9-10
Original file line numberDiff line numberDiff line change
@@ -87,29 +87,28 @@ int Widget_SetAttributeEx(LCUI_Widget w, const char *name, void *value,
8787
int 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

Comments
 (0)