Index: trunk/src/obj_subc.c =================================================================== --- trunk/src/obj_subc.c (revision 20166) +++ trunk/src/obj_subc.c (revision 20167) @@ -488,9 +488,8 @@ } while((text = textlist_first(&src->Text)) != NULL) { - textlist_remove(text); - textlist_append(&dst->Text, text); - PCB_SET_PARENT(text, layer, dst); + pcb_text_unreg(text); + pcb_text_reg(dst, text); PCB_FLAG_CLEAR(PCB_FLAG_WARN | PCB_FLAG_FOUND | PCB_FLAG_SELECTED, text); if (!has_refdes_text && (text->TextString != NULL) && (strstr(text->TextString, "%a.parent.refdes%") != NULL)) has_refdes_text = 1; Index: trunk/src/obj_text.c =================================================================== --- trunk/src/obj_text.c (revision 20166) +++ trunk/src/obj_text.c (revision 20167) @@ -60,6 +60,24 @@ /*** allocation ***/ +void pcb_text_reg(pcb_layer_t *layer, pcb_text_t *text) +{ + textlist_append(&layer->Text, text); + assert(layer->parent_type == PCB_PARENT_DATA); + pcb_obj_id_reg(layer->parent.data, text); + PCB_SET_PARENT(text, layer, layer); +} + +void pcb_text_unreg(pcb_text_t *text) +{ + pcb_layer_t *layer = text->parent.layer; + assert(text->parent_type == PCB_PARENT_LAYER); + textlist_remove(text); + assert(layer->parent_type == PCB_PARENT_DATA); + pcb_obj_id_del(layer->parent.data, text); + PCB_SET_PARENT(text, layer, NULL); +} + pcb_text_t *pcb_text_alloc(pcb_layer_t * layer) { pcb_text_t *new_obj; @@ -67,17 +85,16 @@ new_obj = calloc(sizeof(pcb_text_t), 1); new_obj->type = PCB_OBJ_TEXT; new_obj->Attributes.post_change = pcb_obj_attrib_post_change; - PCB_SET_PARENT(new_obj, layer, layer); - textlist_append(&layer->Text, new_obj); + pcb_text_reg(layer, new_obj); return new_obj; } -void pcb_text_free(pcb_text_t * data) +void pcb_text_free(pcb_text_t *text) { - textlist_remove(data); - free(data); + pcb_text_unreg(text); + free(text); } /*** utility ***/ @@ -406,8 +423,8 @@ pcb_r_delete_entry(srcly->text_tree, (pcb_box_t *) text); pcb_poly_restore_to_poly(ctx->buffer.src, PCB_OBJ_TEXT, srcly, text); - textlist_remove(text); - textlist_append(&dstly->Text, text); + pcb_text_unreg(text); + pcb_text_reg(dstly, text); if (!dstly->text_tree) dstly->text_tree = pcb_r_create_tree(); @@ -414,8 +431,6 @@ pcb_r_insert_entry(dstly->text_tree, (pcb_box_t *) text); pcb_poly_clear_from_poly(ctx->buffer.dst, PCB_OBJ_TEXT, dstly, text); - PCB_SET_PARENT(text, layer, dstly); - return text; } @@ -599,8 +614,8 @@ pcb_poly_restore_to_poly(PCB->Data, PCB_OBJ_TEXT, Source, text); pcb_r_delete_entry(Source->text_tree, (pcb_box_t *) text); - textlist_remove(text); - textlist_append(&Destination->Text, text); + pcb_text_unreg(text); + pcb_text_reg(Destination, text); if (pcb_layer_flags_(Destination) & PCB_LYT_BOTTOM) PCB_FLAG_SET(PCB_FLAG_ONSOLDER, text); /* get the text mirrored on display */ @@ -614,8 +629,6 @@ pcb_r_insert_entry(Destination->text_tree, (pcb_box_t *) text); pcb_poly_clear_from_poly(PCB->Data, PCB_OBJ_TEXT, Destination, text); - PCB_SET_PARENT(text, layer, Destination); - return text; } Index: trunk/src/obj_text.h =================================================================== --- trunk/src/obj_text.h (revision 20166) +++ trunk/src/obj_text.h (revision 20167) @@ -71,6 +71,9 @@ void pcb_text_set_font(pcb_layer_t *layer, pcb_text_t *text, pcb_font_id_t fid); void pcb_text_update(pcb_layer_t *layer, pcb_text_t *text); +void pcb_text_reg(pcb_layer_t *layer, pcb_text_t *text); +void pcb_text_unreg(pcb_text_t *text); + void pcb_text_pre(pcb_text_t *text); void pcb_text_post(pcb_text_t *text);