Index: trunk/src/obj_arc.c =================================================================== --- trunk/src/obj_arc.c (revision 20159) +++ trunk/src/obj_arc.c (revision 20160) @@ -56,6 +56,24 @@ static int pcb_arc_end_addr = 1; int *pcb_arc_start_ptr = NULL, *pcb_arc_end_ptr = &pcb_arc_end_addr; +void pcb_arc_reg(pcb_layer_t *layer, pcb_arc_t *arc) +{ + arclist_append(&layer->Arc, arc); + assert(layer->parent_type == PCB_PARENT_DATA); + pcb_obj_id_reg(layer->parent.data, arc); + PCB_SET_PARENT(arc, layer, layer); +} + +void pcb_arc_unreg(pcb_arc_t *arc) +{ + pcb_layer_t *layer = arc->parent.layer; + assert(arc->parent_type == PCB_PARENT_LAYER); + arclist_remove(arc); + assert(layer->parent_type == PCB_PARENT_DATA); + pcb_obj_id_del(layer->parent.data, arc); + PCB_SET_PARENT(arc, layer, NULL); +} + pcb_arc_t *pcb_arc_alloc(pcb_layer_t * layer) { pcb_arc_t *new_obj; @@ -63,9 +81,9 @@ new_obj = calloc(sizeof(pcb_arc_t), 1); new_obj->type = PCB_OBJ_ARC; new_obj->Attributes.post_change = pcb_obj_attrib_post_change; - PCB_SET_PARENT(new_obj, layer, layer); - arclist_append(&layer->Arc, new_obj); + pcb_arc_reg(layer, new_obj); + return new_obj; } @@ -266,10 +284,10 @@ -void pcb_arc_free(pcb_arc_t * data) +void pcb_arc_free(pcb_arc_t *arc) { - arclist_remove(data); - free(data); + pcb_arc_unreg(arc); + free(arc); } @@ -377,8 +395,8 @@ pcb_poly_restore_to_poly(ctx->buffer.src, PCB_OBJ_ARC, srcly, arc); pcb_r_delete_entry(srcly->arc_tree, (pcb_box_t *) arc); - arclist_remove(arc); - arclist_append(&dstly->Arc, arc); + pcb_arc_unreg(arc); + pcb_arc_reg(dstly, arc); PCB_FLAG_CLEAR(PCB_FLAG_FOUND, arc); @@ -387,8 +405,6 @@ pcb_r_insert_entry(dstly->arc_tree, (pcb_box_t *) arc); pcb_poly_clear_from_poly(ctx->buffer.dst, PCB_OBJ_ARC, dstly, arc); - PCB_SET_PARENT(arc, layer, dstly); - return arc; } @@ -613,15 +629,13 @@ { pcb_r_delete_entry(Source->arc_tree, (pcb_box_t *) arc); - arclist_remove(arc); - arclist_append(&Destination->Arc, arc); + pcb_arc_unreg(arc); + pcb_arc_reg(Destination, arc); if (!Destination->arc_tree) Destination->arc_tree = pcb_r_create_tree(); pcb_r_insert_entry(Destination->arc_tree, (pcb_box_t *) arc); - PCB_SET_PARENT(arc, layer, Destination); - return arc; } Index: trunk/src/obj_arc.h =================================================================== --- trunk/src/obj_arc.h (revision 20159) +++ trunk/src/obj_arc.h (revision 20160) @@ -52,6 +52,9 @@ pcb_arc_t *pcb_arc_dup_at(pcb_layer_t *dst, pcb_arc_t *src, pcb_coord_t dx, pcb_coord_t dy); void *pcb_arc_destroy(pcb_layer_t *Layer, pcb_arc_t *Arc); +void pcb_arc_reg(pcb_layer_t *layer, pcb_arc_t *arc); +void pcb_arc_unreg(pcb_arc_t *arc); + /* Add objects without creating them or making any "sanity modifications" to them */ void pcb_add_arc_on_layer(pcb_layer_t *Layer, pcb_arc_t *Arc); Index: trunk/src/obj_common.h =================================================================== --- trunk/src/obj_common.h (revision 20159) +++ trunk/src/obj_common.h (revision 20160) @@ -216,6 +216,15 @@ /* Returns the first invalid character of an ID (terminal, refdes) or NULL */ const char *pcb_obj_id_invalid(const char *id); +#define pcb_obj_id_reg(data, obj) \ + do { \ + pcb_any_obj_t *__obj__ = (pcb_any_obj_t *)(obj); \ + htip_set(&(data)->id2obj, __obj__->ID, __obj__); \ + } while(0) + +#define pcb_obj_id_del(data, obj) \ + htip_pop(&(data)->id2obj, (obj)->ID) + #define pcb_hidden_floater(obj) (conf_core.editor.hide_names && PCB_FLAG_TEST(PCB_FLAG_FLOATER, (obj))) /* Returns whether a subc part object is editable (not under the subc lock) */ Index: trunk/src/obj_subc.c =================================================================== --- trunk/src/obj_subc.c (revision 20159) +++ trunk/src/obj_subc.c (revision 20160) @@ -483,9 +483,8 @@ } while((arc = arclist_first(&src->Arc)) != NULL) { - arclist_remove(arc); - arclist_append(&dst->Arc, arc); - PCB_SET_PARENT(arc, layer, dst); + pcb_arc_unreg(arc); + pcb_arc_reg(dst, arc); PCB_FLAG_CLEAR(PCB_FLAG_WARN | PCB_FLAG_FOUND | PCB_FLAG_SELECTED, arc); }