Index: trunk/src/obj_arc.c =================================================================== --- trunk/src/obj_arc.c (revision 27960) +++ trunk/src/obj_arc.c (revision 27961) @@ -289,6 +289,8 @@ void pcb_arc_free(pcb_arc_t *arc) { + if ((arc->parent.layer != NULL) && (arc->parent.layer->arc_tree != NULL)) + pcb_r_delete_entry(arc->parent.layer->arc_tree, (pcb_box_t *)arc); pcb_attribute_free(&arc->Attributes); pcb_arc_unreg(arc); free(arc); Index: trunk/src/obj_line.c =================================================================== --- trunk/src/obj_line.c (revision 27960) +++ trunk/src/obj_line.c (revision 27961) @@ -106,6 +106,8 @@ void pcb_line_free(pcb_line_t *line) { + if ((line->parent.layer != NULL) && (line->parent.layer->line_tree != NULL)) + pcb_r_delete_entry(line->parent.layer->line_tree, (pcb_box_t *)line); pcb_attribute_free(&line->Attributes); pcb_line_unreg(line); free(line); Index: trunk/src/obj_poly.c =================================================================== --- trunk/src/obj_poly.c (revision 27960) +++ trunk/src/obj_poly.c (revision 27961) @@ -107,6 +107,8 @@ void pcb_poly_free(pcb_poly_t *poly) { + if ((poly->parent.layer != NULL) && (poly->parent.layer->polygon_tree != NULL)) + pcb_r_delete_entry(poly->parent.layer->polygon_tree, (pcb_box_t *)poly); pcb_attribute_free(&poly->Attributes); pcb_poly_unreg(poly); free(poly); Index: trunk/src/obj_pstk.c =================================================================== --- trunk/src/obj_pstk.c (revision 27960) +++ trunk/src/obj_pstk.c (revision 27961) @@ -105,6 +105,8 @@ void pcb_pstk_free(pcb_pstk_t *ps) { + if ((ps->parent.data != NULL) && (ps->parent.data->padstack_tree != NULL)) + pcb_r_delete_entry(ps->parent.data->padstack_tree, (pcb_box_t *)ps); pcb_attribute_free(&ps->Attributes); pcb_pstk_unreg(ps); free(ps->thermals.shape); Index: trunk/src/obj_rat.c =================================================================== --- trunk/src/obj_rat.c (revision 27960) +++ trunk/src/obj_rat.c (revision 27961) @@ -82,6 +82,8 @@ void pcb_rat_free(pcb_rat_t *rat) { + if ((rat->parent.data != NULL) && (rat->parent.data->rat_tree != NULL)) + pcb_r_delete_entry(rat->parent.data->rat_tree, (pcb_box_t *)rat); pcb_rat_unreg(rat); free(rat->anchor[0]); free(rat->anchor[1]); Index: trunk/src/obj_subc.c =================================================================== --- trunk/src/obj_subc.c (revision 27960) +++ trunk/src/obj_subc.c (revision 27961) @@ -131,6 +131,8 @@ void pcb_subc_free(pcb_subc_t *sc) { + if ((sc->parent.data != NULL) && (sc->parent.data->subc_tree != NULL)) + pcb_r_delete_entry(sc->parent.data->subc_tree, (pcb_box_t *)sc); pcb_attribute_free(&sc->Attributes); pcb_term_uninit(&sc->terminals); pcb_subc_unreg(sc); Index: trunk/src/obj_text.c =================================================================== --- trunk/src/obj_text.c (revision 27960) +++ trunk/src/obj_text.c (revision 27961) @@ -104,6 +104,8 @@ void pcb_text_free(pcb_text_t *text) { + if ((text->parent.layer != NULL) && (text->parent.layer->text_tree != NULL)) + pcb_r_delete_entry(text->parent.layer->text_tree, (pcb_box_t *)text); pcb_attribute_free(&text->Attributes); pcb_text_unreg(text); free(text->TextString);