Index: trunk/src/obj_subc.c =================================================================== --- trunk/src/obj_subc.c (revision 28116) +++ trunk/src/obj_subc.c (revision 28117) @@ -958,6 +958,7 @@ if ((pcb_brave & PCB_BRAVE_CLIPBATCH) && (Data != NULL)) pcb_data_clip_inhibit_inc(Data); + pcb_subc_part_changed_inhibit_inc(sc); switch(batch_undo) { case PCB_SUBCOP_UNDO_SUBC: @@ -1050,6 +1051,9 @@ pcb_close_box(&sc->bbox_naked); if (pcb_data_get_top(Data) != NULL) pcb_r_insert_entry(Data->subc_tree, (pcb_box_t *)sc); + + sc->part_changed_bbox_dirty = 0; /* we've just recalculated the bbox */ + pcb_subc_part_changed_inhibit_dec(sc); DrawSubc(sc); switch(batch_undo) { @@ -1924,18 +1928,45 @@ return &sc->data->Layer[n]; } +PCB_INLINE void pcb_subc_part_changed__(pcb_subc_t *sc, int force) +{ + /* can't do this incrementally: if a boundary object is smaller than before + it has to make the subc bbox smaller too */ + if (force || sc->part_changed_bbox_dirty) { + pcb_subc_bbox(sc); + sc->part_changed_bbox_dirty = 0; + } +} + + void pcb_subc_part_changed_(pcb_any_obj_t *obj) { pcb_subc_t *sc = pcb_obj_parent_subc(obj); if (sc == NULL) return; + if (sc->part_changed_inhibit) + sc->part_changed_bbox_dirty = 1; + else + pcb_subc_part_changed__(sc, 1); +} - /* can't do this incrementally: if a boundary object is smaller than before - it has to make the subc bbox smaller too */ - pcb_subc_bbox(sc); +void pcb_subc_part_changed_inhibit_inc(pcb_subc_t *sc) +{ + sc->part_changed_inhibit++; } +void pcb_subc_part_changed_inhibit_dec(pcb_subc_t *sc) +{ + if (sc->part_changed_inhibit > 0) { + sc->part_changed_inhibit--; + if (sc->part_changed_inhibit == 0) + pcb_subc_part_changed__(sc, 0); + } + else + pcb_message(PCB_MSG_ERROR, "Internal error: pcb_subc_part_changed_inhibit_dec(): underflow; please reprot this bug\n"); +} + const char *pcb_subc_name(pcb_subc_t *subc, const char *local_name) { const char *val; Index: trunk/src/obj_subc.h =================================================================== --- trunk/src/obj_subc.h (revision 28116) +++ trunk/src/obj_subc.h (revision 28117) @@ -52,6 +52,8 @@ pcb_line_t *aux_cache[PCB_SUBCH_max]; pcb_layer_t *aux_layer; const char *refdes; /* cached from attributes for fast lookup */ + int part_changed_inhibit; + unsigned part_changed_bbox_dirty:1; /* part_changed_inhibit_dec() should recalculate the bbox */ gdl_elem_t link; }; @@ -149,7 +151,10 @@ /* Update the subcircuit (e.g. bbox) after a part of the subcircuit has changed */ void pcb_subc_part_changed_(pcb_any_obj_t *obj); #define pcb_subc_part_changed(obj) pcb_subc_part_changed_((pcb_any_obj_t *)obj) +void pcb_subc_part_changed_inhibit_inc(pcb_subc_t *sc); +void pcb_subc_part_changed_inhibit_dec(pcb_subc_t *sc); + /*** subc creation helpers ***/ /* Create the aux layer for a subc, set origin to ox;oy and rotation to rot */