Index: trunk/src/change.c =================================================================== --- trunk/src/change.c (revision 27778) +++ trunk/src/change.c (revision 27779) @@ -776,7 +776,7 @@ default: term_name:; - if (parent_subc != NULL) { + { name = pcb_hid_prompt_for("Enter terminal ID:", PCB_EMPTY(obj->term), "Change terminal ID"); if (name != NULL) { pcb_term_undoable_rename(PCB, obj, name); Index: trunk/src/obj_term.c =================================================================== --- trunk/src/obj_term.c (revision 27778) +++ trunk/src/obj_term.c (revision 27779) @@ -174,7 +174,7 @@ static int undo_term_rename_swap(void *udata) { - char *old_term = NULL; + char *old_term = NULL, *autofree = NULL; pcb_subc_t *subc; term_rename_t *r = udata; int res = 0; @@ -181,15 +181,14 @@ pcb_flag_t ftmp; subc = pcb_obj_parent_subc(r->obj); - if (subc == NULL) { - pcb_message(PCB_MSG_ERROR, "Undo error: terminal rename: object %ld not part of a terminal\n", r->obj->ID); - return -1; - } /* remove from previous terminal */ if (r->obj->term != NULL) { old_term = pcb_strdup(r->obj->term); - res |= pcb_term_del(&subc->terminals, r->obj); + if (subc != NULL) + res |= pcb_term_del(&subc->terminals, r->obj); + else + pcb_attribute_remove(&r->obj->Attributes, "term"); pcb_obj_invalidate_label(r->obj->type, r->obj->parent.any, r->obj, r->obj); r->obj->term = NULL; } @@ -196,7 +195,10 @@ /* add to new terminal */ if (*r->str != '\0') { - res |= pcb_term_add(&subc->terminals, r->str, r->obj); + if (subc != NULL) + res |= pcb_term_add(&subc->terminals, r->str, r->obj); + else + autofree = r->obj->term = pcb_strdup(r->str); pcb_obj_invalidate_label(r->obj->type, r->obj->parent.any, r->obj, r->obj); } @@ -222,6 +224,7 @@ if (r->obj->type == PCB_OBJ_POLY) pcb_poly_init_clip(r->obj->parent.layer->parent.data, r->obj->parent.layer, (pcb_poly_t *)r->obj); + free(autofree); return res; } @@ -244,7 +247,6 @@ { int nname_len = 0, oname_len = 0, len; term_rename_t *r; - pcb_subc_t *subc; if ((new_name == NULL) && (obj->term == NULL)) return PCB_TERM_ERR_NO_CHANGE; @@ -252,10 +254,6 @@ if (((new_name != NULL) && (obj->term != NULL)) && (strcmp(new_name, obj->term) == 0)) return PCB_TERM_ERR_NO_CHANGE; - subc = pcb_obj_parent_subc(obj); - if (subc == NULL) - return PCB_TERM_ERR_NOT_IN_SUBC; - if (new_name != NULL) nname_len = strlen(new_name); Index: trunk/src/obj_term.h =================================================================== --- trunk/src/obj_term.h (revision 27778) +++ trunk/src/obj_term.h (revision 27779) @@ -46,7 +46,6 @@ PCB_TERM_ERR_ALREADY_TERMINAL, /* object is already in a terminal, can not be added in another */ PCB_TERM_ERR_NOT_IN_TERMINAL, /* object is not part of any terminal */ PCB_TERM_ERR_TERM_NOT_FOUND, - PCB_TERM_ERR_NOT_IN_SUBC, PCB_TERM_ERR_NO_CHANGE, PCB_TERM_ERR_INVALID_NAME } pcb_term_err_t;