mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-12-22 23:14:36 +02:00
purge unused measurement instances
Instances of measurements referencing vectors not instantiated were only partially initialized (because only inst_meas_hint was called on them but never inst_meas) but still left in the list of instances. They were thus displayed, producing confusing results. We now trace a measurement instance's validity and remove all invalid instances at the end of instantiate_meas.
This commit is contained in:
parent
5130707371
commit
43928dbbf3
6
inst.c
6
inst.c
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* inst.c - Instance structures
|
||||
*
|
||||
* Written 2009-2011 by Werner Almesberger
|
||||
* Copyright 2009-2011 by Werner Almesberger
|
||||
* Written 2009-2012 by Werner Almesberger
|
||||
* Copyright 2009-2012 by Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -1051,6 +1051,7 @@ int inst_meas(struct obj *obj, struct coord from, struct coord to)
|
||||
assert(inst);
|
||||
inst->base = from;
|
||||
inst->u.meas.end = to;
|
||||
inst->u.meas.valid = 1;
|
||||
/* @@@ we still need to consider the text size as well */
|
||||
update_bbox(&inst->bbox, from);
|
||||
update_bbox(&inst->bbox, to);
|
||||
@ -1073,6 +1074,7 @@ void inst_meas_hint(struct obj *obj, unit_type offset)
|
||||
inst = add_inst(&meas_ops, ip_meas, zero);
|
||||
inst->obj = obj;
|
||||
inst->u.meas.offset = offset;
|
||||
inst->u.meas.valid = 0;
|
||||
inst->active = 1; /* measurements are always active */
|
||||
}
|
||||
|
||||
|
5
inst.h
5
inst.h
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* inst.h - Instance structures
|
||||
*
|
||||
* Written 2009, 2010 by Werner Almesberger
|
||||
* Copyright 2009, 2010 by Werner Almesberger
|
||||
* Written 2009, 2010, 2012 by Werner Almesberger
|
||||
* Copyright 2009, 2010, 2012 by Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -113,6 +113,7 @@ struct inst {
|
||||
struct {
|
||||
struct coord end;
|
||||
double offset;
|
||||
int valid; /* only set if references exist */
|
||||
} meas;
|
||||
} u;
|
||||
struct inst *next;
|
||||
|
21
meas.c
21
meas.c
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* meas.c - Measurements
|
||||
*
|
||||
* Written 2009, 2010 by Werner Almesberger
|
||||
* Copyright 2009, 2010 by Werner Almesberger
|
||||
* Written 2009, 2010, 2012 by Werner Almesberger
|
||||
* Copyright 2009, 2010, 2012 by Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -294,6 +294,22 @@ static int instantiate_meas_pkg(int n_frames)
|
||||
}
|
||||
|
||||
|
||||
static void purge_meas(struct pkg *pkg)
|
||||
{
|
||||
struct inst **anchor, *inst;
|
||||
|
||||
anchor = pkg->insts+ip_meas;
|
||||
while (*anchor)
|
||||
if ((*anchor)->u.meas.valid) {
|
||||
anchor = &(*anchor)->next;
|
||||
} else {
|
||||
inst = *anchor;
|
||||
*anchor = inst->next;
|
||||
free(inst);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int instantiate_meas(int n_frames)
|
||||
{
|
||||
struct pkg *pkg;
|
||||
@ -304,6 +320,7 @@ int instantiate_meas(int n_frames)
|
||||
inst_select_pkg(pkg->name);
|
||||
if (!instantiate_meas_pkg(n_frames))
|
||||
return 0;
|
||||
purge_meas(pkg);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user