Index: trunk/src/buffer.c =================================================================== --- trunk/src/buffer.c (revision 29974) +++ trunk/src/buffer.c (revision 29975) @@ -133,6 +133,13 @@ /* when an edit-object is moved to buffer, the corresponding subc obj needs to be moved too */ if (subc != NULL) { + /* make sure the same subc is not copied twice by detecting a copy already done from the same subc to the same buffer */ + pcb_subc_t *bsc; + gdl_iterator_t it; + subclist_foreach(&ctx->buffer.dst->subc, &it, bsc) { + if (bsc->copied_from_ID == subc->ID) + return 1; + } pcb_subcop_add_to_buffer(ctx, subc); return 1; } Index: trunk/src/obj_subc.c =================================================================== --- trunk/src/obj_subc.c (revision 29974) +++ trunk/src/obj_subc.c (revision 29975) @@ -838,6 +838,8 @@ else sc->ID = pcb_create_ID_get(); + sc->copied_from_ID = src->ID; + minuid_cpy(sc->uid, src->uid); pcb_subc_reg(dst, sc); Index: trunk/src/obj_subc.h =================================================================== --- trunk/src/obj_subc.h (revision 29974) +++ trunk/src/obj_subc.h (revision 29975) @@ -57,6 +57,7 @@ int part_changed_inhibit; unsigned part_changed_bbox_dirty:1; /* part_changed_inhibit_dec() should recalculate the bbox */ unsigned auto_termname_display:1; /* display bit, not saved or loaded, only toggled by Display() on subc */ + long int copied_from_ID; /* temporary storage during operation: if a subc is a copy of another subc in the same operation, keep the ID of the original subc to avoid duplicate copies */ gdl_elem_t link; };