diff --git a/gui_meas.c b/gui_meas.c index 8f1b40b..29dd317 100644 --- a/gui_meas.c +++ b/gui_meas.c @@ -269,7 +269,8 @@ static int end_new_meas(struct inst *from, struct inst *to) if (from == to) return 0; /* it's safe to pass "from" here, but we may change it later */ - obj = new_obj(ot_meas, from); + obj = new_obj_unconnected(ot_meas, from); + connect_obj(root_frame, obj); meas = &obj->u.meas; meas->label = NULL; switch (mode) { diff --git a/gui_tool.c b/gui_tool.c index 598e82f..1fa4fce 100644 --- a/gui_tool.c +++ b/gui_tool.c @@ -83,9 +83,9 @@ static struct vec *new_vec(struct inst *base) } -struct obj *new_obj(enum obj_type type, struct inst *base) +struct obj *new_obj_unconnected(enum obj_type type, struct inst *base) { - struct obj *obj, **walk; + struct obj *obj; obj = alloc_type(struct obj); obj->type = type; @@ -93,8 +93,25 @@ struct obj *new_obj(enum obj_type type, struct inst *base) obj->base = inst_get_vec(base); obj->next = NULL; obj->lineno = 0; - for (walk = &active_frame->objs; *walk; walk = &(*walk)->next); + return obj; +} + + +void connect_obj(struct frame *frame, struct obj *obj) +{ + struct obj **walk; + + for (walk = &frame->objs; *walk; walk = &(*walk)->next); *walk = obj; +} + + +static struct obj *new_obj(enum obj_type type, struct inst *base) +{ + struct obj *obj; + + obj = new_obj_unconnected(type, base); + connect_obj(active_frame, obj); return obj; } diff --git a/gui_tool.h b/gui_tool.h index 4d79c37..e28a8f2 100644 --- a/gui_tool.h +++ b/gui_tool.h @@ -57,7 +57,8 @@ void tool_redraw(void); * compilation unit. */ -struct obj *new_obj(enum obj_type type, struct inst *base); +struct obj *new_obj_unconnected(enum obj_type type, struct inst *base); +void connect_obj(struct frame *frame, struct obj *obj); struct pix_buf *draw_move_line_common(struct inst *inst, struct coord end, struct coord pos, int i); struct pix_buf *drag_new_line(struct inst *from, struct coord to);