Index: trunk/src/obj_common.c =================================================================== --- trunk/src/obj_common.c (revision 28839) +++ trunk/src/obj_common.c (revision 28840) @@ -125,48 +125,35 @@ return ID++; } -static void pcb_attribute_copy_all_smart(pcb_attribute_list_t *dest, const pcb_attribute_list_t *src, pcb_any_obj_t *dstobj) +static void pcb_attribute_copy_all_smart(pcb_attribute_list_t *dest, const pcb_attribute_list_t *src, pcb_any_obj_t *dstobj, pcb_any_obj_t *copy_from_any) { int i, exto = 0; - const char *subcobj; + pcb_subc_t *copy_from = NULL; + if (copy_from_any != NULL) { + if (PCB_FLAG_TEST(PCB_FLAG_FLOATER, copy_from_any)) + copy_from = pcb_obj_parent_subc(copy_from_any); + else if (copy_from_any->type == PCB_OBJ_SUBC) + copy_from = (pcb_subc_t *)copy_from_any; + + if (pcb_extobj_get(copy_from) == NULL) + copy_from = NULL; + } + for (i = 0; i < src->Number; i++) pcb_attribute_put(dest, src->List[i].name, src->List[i].value); - if (exto) { - pcb_subc_t *copy_from = NULL; - if (subcobj != NULL) { - pcb_data_t *data; - - if (dstobj->parent_type == PCB_PARENT_DATA) - data = dstobj->parent.data; - else if (dstobj->parent_type == PCB_PARENT_LAYER) - data = dstobj->parent.layer->parent.data; - else - data = NULL; - - if (data != NULL) { - char *end; - long id = strtol(subcobj, &end, 10); - if (*end == '\0') { - copy_from = htip_get(&data->id2obj, id); - if ((copy_from != NULL) && (copy_from->type != PCB_OBJ_SUBC)) - copy_from = NULL; - } - } - } + if (copy_from != NULL) pcb_extobj_new_subc(dstobj, copy_from); - } } -void pcb_obj_add_attribs(void *obj, const pcb_attribute_list_t *src, pcb_bool smart) +void pcb_obj_add_attribs(pcb_any_obj_t *o, const pcb_attribute_list_t *src, pcb_any_obj_t *copy_from) { - pcb_any_obj_t *o = obj; if (src == NULL) return; - if (smart) - pcb_attribute_copy_all_smart(&o->Attributes, src, obj); + if (copy_from) + pcb_attribute_copy_all_smart(&o->Attributes, src, o, copy_from); else pcb_attribute_copy_all(&o->Attributes, src); } Index: trunk/src/obj_common.h =================================================================== --- trunk/src/obj_common.h (revision 28839) +++ trunk/src/obj_common.h (revision 28840) @@ -166,10 +166,11 @@ void pcb_create_ID_reset(void); long int pcb_create_ID_get(void); -/* Copy src attributes into obj's attributes, overwriting anything. If smart - is true, be smart about extobj and other attribute side effects - (some of those will not be copied or will be changed) */ -void pcb_obj_add_attribs(void *obj, const pcb_attribute_list_t *src, pcb_bool smart); +/* Copy src attributes into obj's attributes, overwriting anything. If src_obj + is not NULL, it is the source object - be smart about extobj and other + attribute side effects (some of those will not be copied or will be + changed); src_obj should be the objec src attributes are coming from */ +void pcb_obj_add_attribs(pcb_any_obj_t *obj, const pcb_attribute_list_t *src, pcb_any_obj_t *src_obj); /* --------------------------------------------------------------------------- * Do not change the following definitions even if they're not very Index: trunk/src/route.c =================================================================== --- trunk/src/route.c (revision 28839) +++ trunk/src/route.c (revision 28840) @@ -497,9 +497,9 @@ p_route->flags); if (line) { pcb_added_lines++; - pcb_obj_add_attribs(line, PCB->pen_attr, pcb_true); + pcb_obj_add_attribs(line, PCB->pen_attr, NULL); if (attr_src != NULL) - pcb_obj_add_attribs(line, &attr_src->Attributes, pcb_true); + pcb_obj_add_attribs(line, &attr_src->Attributes, attr_src); pcb_line_invalidate_draw(layer, line); pcb_undo_add_obj_to_create(PCB_OBJ_LINE, layer, line, line); applied = 1; @@ -524,9 +524,9 @@ p_route->flags, pcb_true); if (arc) { pcb_added_lines++; - pcb_obj_add_attribs(arc, PCB->pen_attr, pcb_true); + pcb_obj_add_attribs(arc, PCB->pen_attr, NULL); if (attr_src != NULL) - pcb_obj_add_attribs(arc, &attr_src->Attributes, pcb_true); + pcb_obj_add_attribs(arc, &attr_src->Attributes, attr_src); pcb_undo_add_obj_to_create(PCB_OBJ_ARC, layer, arc, arc); pcb_arc_invalidate_draw(layer, arc); applied = 1; @@ -636,9 +636,9 @@ p_route->flags, pcb_true); if (arc) { pcb_added_lines++; - pcb_obj_add_attribs(arc, PCB->pen_attr, pcb_true); + pcb_obj_add_attribs(arc, PCB->pen_attr, NULL); if (attr_src != NULL) - pcb_obj_add_attribs(arc, &attr_src->Attributes, pcb_true); + pcb_obj_add_attribs(arc, &attr_src->Attributes, attr_src); pcb_undo_add_obj_to_create(PCB_OBJ_ARC, layer, arc, arc); pcb_arc_invalidate_draw(layer, arc); applied = 1; @@ -661,9 +661,9 @@ p_route->flags); if (line) { pcb_added_lines++; - pcb_obj_add_attribs(line, PCB->pen_attr, pcb_true); + pcb_obj_add_attribs(line, PCB->pen_attr, NULL); if (attr_src != NULL) - pcb_obj_add_attribs(line, &attr_src->Attributes, pcb_true); + pcb_obj_add_attribs(line, &attr_src->Attributes, attr_src); pcb_line_invalidate_draw(layer, line); pcb_undo_add_obj_to_create(PCB_OBJ_LINE, layer, line, line); applied = 1; Index: trunk/src/tool_arc.c =================================================================== --- trunk/src/tool_arc.c (revision 28839) +++ trunk/src/tool_arc.c (revision 28840) @@ -116,7 +116,7 @@ conf_core.design.line_thickness, 2 * conf_core.design.clearance, pcb_flag_make(conf_core.editor.clear_line ? PCB_FLAG_CLEARLINE : 0), pcb_true))) { - pcb_obj_add_attribs(arc, pcb->pen_attr, pcb_true); + pcb_obj_add_attribs(arc, pcb->pen_attr, NULL); pcb_arc_get_end(arc, 1, &pcb_crosshair.AttachedBox.Point2.X, &pcb_crosshair.AttachedBox.Point2.Y); pcb_crosshair.AttachedBox.Point1.X = pcb_crosshair.AttachedBox.Point2.X; pcb_crosshair.AttachedBox.Point1.Y = pcb_crosshair.AttachedBox.Point2.Y; Index: trunk/src/tool_line.c =================================================================== --- trunk/src/tool_line.c (revision 28839) +++ trunk/src/tool_line.c (revision 28840) @@ -198,7 +198,7 @@ pcb_crosshair.AttachedLine.Point1.Y, conf_core.design.via_drilling_hole, conf_core.design.via_thickness, conf_core.design.clearance, 0, PCB_PSTK_COMPAT_ROUND, pcb_true)) != NULL)) { - pcb_obj_add_attribs(ps, pcb->pen_attr, pcb_true); + pcb_obj_add_attribs(ps, pcb->pen_attr, NULL); pcb_undo_add_obj_to_create(PCB_OBJ_PSTK, ps, ps, ps); } @@ -269,7 +269,7 @@ pcb_pstk_t *ps = NULL; pcb_added_lines++; - pcb_obj_add_attribs(line, pcb->pen_attr, pcb_true); + pcb_obj_add_attribs(line, pcb->pen_attr, NULL); pcb_undo_add_obj_to_create(PCB_OBJ_LINE, PCB_CURRLAYER(pcb), line, line); pcb_line_invalidate_draw(PCB_CURRLAYER(pcb), line); /* place a via if vias are visible, the layer is @@ -290,7 +290,7 @@ pcb_crosshair.AttachedLine.Point1.Y, conf_core.design.via_drilling_hole, conf_core.design.via_thickness, conf_core.design.clearance, 0, PCB_PSTK_COMPAT_ROUND, pcb_true)) != NULL)) { - pcb_obj_add_attribs(ps, pcb->pen_attr, pcb_true); + pcb_obj_add_attribs(ps, pcb->pen_attr, NULL); pcb_undo_add_obj_to_create(PCB_OBJ_PSTK, ps, ps, ps); pcb_pstk_invalidate_draw(ps); } @@ -312,7 +312,7 @@ pcb_flag_make((conf_core.editor.auto_drc ? PCB_FLAG_FOUND : 0) | (conf_core.editor.clear_line ? PCB_FLAG_CLEARLINE : 0)))) != NULL) { pcb_added_lines++; - pcb_obj_add_attribs(line, pcb->pen_attr, pcb_true); + pcb_obj_add_attribs(line, pcb->pen_attr, NULL); pcb_undo_add_obj_to_create(PCB_OBJ_LINE, PCB_CURRLAYER(pcb), line, line); pcb_undo_inc_serial(); pcb_line_invalidate_draw(PCB_CURRLAYER(pcb), line); Index: trunk/src/tool_rectangle.c =================================================================== --- trunk/src/tool_rectangle.c (revision 28839) +++ trunk/src/tool_rectangle.c (revision 28840) @@ -80,7 +80,7 @@ pcb_crosshair.AttachedBox.Point2.Y, 2 * conf_core.design.clearance, pcb_flag_make(flags))) != NULL) { - pcb_obj_add_attribs(polygon, pcb->pen_attr, pcb_true); + pcb_obj_add_attribs(polygon, pcb->pen_attr, NULL); pcb_undo_add_obj_to_create(PCB_OBJ_POLY, layer, polygon, polygon); pcb_undo_inc_serial(); pcb_poly_invalidate_draw(layer, polygon); Index: trunk/src/tool_via.c =================================================================== --- trunk/src/tool_via.c (revision 28839) +++ trunk/src/tool_via.c (revision 28840) @@ -73,7 +73,7 @@ if (ps == NULL) return; - pcb_obj_add_attribs(ps, pcb->pen_attr, pcb_true); + pcb_obj_add_attribs(ps, pcb->pen_attr, NULL); pcb_undo_add_obj_to_create(PCB_OBJ_PSTK, ps, ps, ps); if (pcb_gui->shift_is_pressed(pcb_gui))