Skip to content

Commit

Permalink
fix(gui): widget attribute value should always be available
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-soft committed Oct 3, 2019
1 parent c9550ac commit 4b0a2ed
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/gui/widget_attribute.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,29 +87,28 @@ int Widget_SetAttributeEx(LCUI_Widget w, const char *name, void *value,
int Widget_SetAttribute(LCUI_Widget w, const char *name, const char *value)
{
int ret;
char *value_str;
char *value_str = NULL;

if (strcmp(name, "disabled") == 0) {
if (!value || strcmp(value, "false") != 0) {
Widget_SetDisabled(w, TRUE);
} else {
Widget_SetDisabled(w, FALSE);
}
return 0;
}
if (value) {
value_str = strdup2(value);
if (!value_str) {
return -ENOMEM;
}
if (strcmp(name, "disabled") == 0) {
if (!value || strcmp(value, "false") != 0) {
Widget_SetDisabled(w, TRUE);
} else {
Widget_SetDisabled(w, FALSE);
}
}
ret = Widget_SetAttributeEx(w, name, value_str,
LCUI_STYPE_STRING, free);
} else {
ret = Widget_SetAttributeEx(w, name, NULL, LCUI_STYPE_NONE,
NULL);
}
if (w->proto && w->proto->setattr) {
w->proto->setattr(w, name, value);
w->proto->setattr(w, name, value_str);
}
return ret;
}
Expand Down

0 comments on commit 4b0a2ed

Please sign in to comment.