Set w->user_data to 'screen' for type=WIDGET_TYPE_LOADSCREEN

This commit is contained in:
Pim van Pelt
2017-12-02 13:37:00 +01:00
parent c3a71a9b69
commit 5a283bd87f

View File

@ -68,6 +68,7 @@ struct widget_t *widget_create_from_json(const char *json) {
char *name = NULL; char *name = NULL;
char *label = NULL; char *label = NULL;
char *img = NULL; char *img = NULL;
char *screen = NULL;
if (json_scanf(json, strlen(json), "{name:%Q,x:%d,y:%d,w:%d,h:%d}", &name, &x, &y, &w, &h) != 5) { if (json_scanf(json, strlen(json), "{name:%Q,x:%d,y:%d,w:%d,h:%d}", &name, &x, &y, &w, &h) != 5) {
LOG(LL_ERROR, ("Incomplete JSON: require 'x', 'y', 'w', 'h' and 'name' fields")); LOG(LL_ERROR, ("Incomplete JSON: require 'x', 'y', 'w', 'h' and 'name' fields"));
@ -80,6 +81,14 @@ struct widget_t *widget_create_from_json(const char *json) {
widget->type=type; widget->type=type;
widget->label=label; widget->label=label;
widget->img=img; widget->img=img;
if (type == WIDGET_TYPE_LOADSCREEN) {
if (json_scanf(json, strlen(json), "{screen:%Q}", &screen) != 1) {
LOG(LL_WARN, ("Widget '%s' is of type LOADSCREEN but does not have attribute 'screen'", widget->name));
} else {
if (widget->user_data) free(widget->user_data);
widget->user_data = screen;
}
}
return widget; return widget;
} }