Index: trunk/src/libcschem/operation.c =================================================================== --- trunk/src/libcschem/operation.c (revision 10310) +++ trunk/src/libcschem/operation.c (revision 10311) @@ -2,7 +2,7 @@ * COPYRIGHT * * cschem - modular/flexible schematics editor - libcschem (core library) - * Copyright (C) 2020,2022 Tibor 'Igor2' Palinkas + * Copyright (C) 2020,2022,2024 Tibor 'Igor2' Palinkas * * (Supported by NLnet NGI0 PET Fund in 2022) * @@ -104,6 +104,9 @@ if (how & CSCH_REM_UNDOABLE) csch_conn_auto_recalc(sheet, obj); + if ((parent != NULL) && (parent->role == CSCH_ROLE_WIRE_NET)) + csch_wirenet_post_remove_checks(sheet, parent, (how & CSCH_REM_UNDOABLE)); + if ((how & CSCH_REM_DEL_EMPTY_PARENT) && (parent != NULL) && (parent->id2obj.used == 0) && (!csch_obj_is_deleted(&parent->hdr))) csch_cnc_remove_(sheet, &parent->hdr, how); Index: trunk/src/libcschem/util_wirenet.c =================================================================== --- trunk/src/libcschem/util_wirenet.c (revision 10310) +++ trunk/src/libcschem/util_wirenet.c (revision 10311) @@ -2,7 +2,7 @@ * COPYRIGHT * * cschem - modular/flexible schematics editor - sch-rnd (executable) - * Copyright (C) 2020,2022,2023 Tibor 'Igor2' Palinkas + * Copyright (C) 2020,2022..2024 Tibor 'Igor2' Palinkas * * (Supported by NLnet NGI0 PET Fund in 2022, Entrust in 2023) * @@ -1260,3 +1260,32 @@ return !(res & csch_RTREE_DIR_FOUND); } +void csch_wirenet_post_remove_checks(csch_sheet_t *sheet, csch_cgrp_t *wn, int undoable) +{ + htip_entry_t *e, *next; + int has_wires = 0; + + /* check if the wirenet has anything else than floaters and connections */ + for(e = htip_first(&wn->id2obj); e != NULL; e = htip_next(&wn->id2obj, e)) { + csch_chdr_t *obj = e->value; + if (!obj->floater && (obj->type != CSCH_CTYPE_CONN)) { + has_wires = 1; + break; + } + } + + if (!has_wires) { + /* remove all floaters */ + for(e = htip_first(&wn->id2obj); e != NULL; e = next) { + csch_chdr_t *obj = e->value; + next = htip_next(&wn->id2obj, e); + if (obj->floater) { + if (undoable) + csch_op_remove(sheet, obj); + else + csch_cnc_remove(sheet, obj); + } + } + } +} + Index: trunk/src/libcschem/util_wirenet.h =================================================================== --- trunk/src/libcschem/util_wirenet.h (revision 10310) +++ trunk/src/libcschem/util_wirenet.h (revision 10311) @@ -51,6 +51,11 @@ other line won't have its endpoint in the middle of the new line */ int csch_is_wireline_safe(csch_sheet_t *sheet, csch_coord_t x1, csch_coord_t y1, csch_coord_t x2, csch_coord_t y2); +/* Called after an object is removed from a wirenet; removes floaters if the + wirenet is empty */ +void csch_wirenet_post_remove_checks(csch_sheet_t *sheet, csch_cgrp_t *wn, int undoable); + + /*** low level ***/ /* Create a new wire line within a wirenet without updating or recalculating