forked from external/yambar
particle/progress-bar: handle tag_for_name() failing
This commit is contained in:
parent
31c015c680
commit
321d1cdc7d
1 changed files with 8 additions and 5 deletions
|
@ -179,13 +179,13 @@ instantiate(const struct particle *particle, const struct tag_set *tags)
|
|||
{
|
||||
const struct private *p = particle->private;
|
||||
const struct tag *tag = tag_for_name(tags, p->tag);
|
||||
assert(tag != NULL);
|
||||
|
||||
long value = tag->as_int(tag);
|
||||
long min = tag->min(tag);
|
||||
long max = tag->max(tag);
|
||||
long value = tag != NULL ? tag->as_int(tag) : 0;
|
||||
long min = tag != NULL ? tag->min(tag) : 0;
|
||||
long max = tag != NULL ? tag->max(tag) : 0;
|
||||
|
||||
LOG_DBG("%s: value=%ld, min=%ld, max=%ld", tag->name(tag), value, min, max);
|
||||
LOG_DBG("%s: value=%ld, min=%ld, max=%ld",
|
||||
tag != NULL ? tag->name(tag) : "<no tag>", value, min, max);
|
||||
|
||||
long fill_count = max == min ? 0 : p->width * value / (max - min);
|
||||
long empty_count = p->width - fill_count;
|
||||
|
@ -224,6 +224,9 @@ instantiate(const struct particle *particle, const struct tag_set *tags)
|
|||
exposable->expose = &expose;
|
||||
exposable->on_mouse = &on_mouse;
|
||||
|
||||
if (tag == NULL)
|
||||
return exposable;
|
||||
|
||||
enum tag_realtime_unit rt = tag->realtime(tag);
|
||||
|
||||
if (rt == TAG_REALTIME_NONE)
|
||||
|
|
Loading…
Add table
Reference in a new issue