Allow marks without labels defined

The labels are optional, so they shouldn't be required when processing
the mark types.
This commit is contained in:
Rodrigo Arias 2024-06-17 13:46:09 +02:00
parent b4d445b378
commit 90f8ae4188

View File

@ -215,12 +215,6 @@ parse_mark(struct ovni_mark_emu *m, const char *typestr, JSON_Value *markval)
return -1; return -1;
} }
JSON_Object *labels = json_object_get_object(mark, "labels");
if (labels == NULL) {
err("json_object_get_object() for labels failed");
return -1;
}
struct mark_type *t = find_mark_type(m, type); struct mark_type *t = find_mark_type(m, type);
if (t == NULL) { if (t == NULL) {
t = create_mark_type(m, type, chan_type, title); t = create_mark_type(m, type, chan_type, title);
@ -239,12 +233,22 @@ parse_mark(struct ovni_mark_emu *m, const char *typestr, JSON_Value *markval)
} }
} }
/* The labels are optional */
if (json_object_has_value(mark, "labels")) {
JSON_Object *labels = json_object_get_object(mark, "labels");
if (labels == NULL) {
err("json_object_get_object() for labels failed");
return -1;
}
/* Now populate the mark type with all value labels */ /* Now populate the mark type with all value labels */
if (parse_labels(t, labels) != 0) { if (parse_labels(t, labels) != 0) {
err("cannot parse labels"); err("cannot parse labels");
return -1; return -1;
} }
}
return 0; return 0;
} }