Index: trunk/src/extobj.c =================================================================== --- trunk/src/extobj.c (revision 28788) +++ trunk/src/extobj.c (revision 28789) @@ -172,20 +172,17 @@ pcb_extobj_edit_geo(edit_obj); } -void pcb_extobj_del_pre(pcb_any_obj_t *edit_obj) +void pcb_extobj_del_pre(pcb_subc_t *sc) { - pcb_subc_t *sc = pcb_extobj_get_subcobj_by_attr(edit_obj); - pcb_extobj_t *eo; + pcb_extobj_t *eo = pcb_extobj_get(sc); + pcb_any_obj_t *edit_obj = NULL; - if (sc == NULL) - return; - - eo = pcb_extobj_get(sc); if ((eo != NULL) && (eo->del_pre != NULL)) eo->del_pre(sc); - pcb_attribute_remove(&edit_obj->Attributes, "extobj::subcobj"); + edit_obj = pcb_extobj_get_editobj(eo, sc); + if (edit_obj != NULL) + pcb_attribute_remove(&edit_obj->Attributes, "extobj::subcobj"); + pcb_attribute_remove(&sc->Attributes, "extobj::editobj"); - - pcb_subc_remove(sc); } Index: trunk/src/extobj.h =================================================================== --- trunk/src/extobj.h (revision 28788) +++ trunk/src/extobj.h (revision 28789) @@ -74,10 +74,14 @@ copy all data from there (including objects). */ void pcb_extobj_new_subc(pcb_any_obj_t *edit_obj, pcb_subc_t *subc_copy_from); -/* called before an edit-obj is removed */ -void pcb_extobj_del_pre(pcb_any_obj_t *edit_obj); +/* Called to remove the subc of an edit object */ +PCB_INLINE void pcb_extobj_del_subc(pcb_any_obj_t *edit_obj); +/* called (by the subc code) before an edit-obj is removed */ +void pcb_extobj_del_pre(pcb_subc_t *edit_obj); + + int pcb_extobj_lookup_idx(const char *name); extern int pcb_extobj_invalid; /* this changes upon each new extobj reg, forcing the caches to be invalidated eventually */ @@ -106,7 +110,7 @@ PCB_INLINE pcb_any_obj_t *pcb_extobj_get_editobj(pcb_extobj_t *eo, pcb_subc_t *obj) { - if (eo->get_editobj != NULL) + if ((eo != NULL) && (eo->get_editobj != NULL)) return eo->get_editobj(obj); return pcb_extobj_get_editobj_by_attr(obj); @@ -198,4 +202,13 @@ eo->chg_attr(subc, key, value); } +PCB_INLINE void pcb_extobj_del_subc(pcb_any_obj_t *edit_obj) +{ + pcb_subc_t *sc = pcb_extobj_get_subcobj_by_attr(edit_obj); + if (sc == NULL) + return; + + pcb_subc_remove(sc); +} + #endif Index: trunk/src/obj_subc.c =================================================================== --- trunk/src/obj_subc.c (revision 28788) +++ trunk/src/obj_subc.c (revision 28789) @@ -133,6 +133,7 @@ void pcb_subc_free(pcb_subc_t *sc) { + pcb_extobj_del_pre(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); Index: trunk/src/remove.c =================================================================== --- trunk/src/remove.c (revision 28788) +++ trunk/src/remove.c (revision 28789) @@ -99,7 +99,7 @@ ctx.remove.pcb = PCB; ctx.remove.destroy_target = NULL; - pcb_extobj_del_pre(Ptr2); + pcb_extobj_del_subc(Ptr2); ptr = pcb_object_operation(&RemoveFunctions, &ctx, Type, Ptr1, Ptr2, Ptr3); pcb_draw(); return ptr;