Index: trunk/src/idpath.c =================================================================== --- trunk/src/idpath.c (revision 34218) +++ trunk/src/idpath.c (revision 34219) @@ -246,7 +246,7 @@ { pcb_data_t *data; if (path->uilayer_addr > 0) { - data = pcb->Data; + data = pcb_uilayer_dummy_data; } else if (path->data_addr == 1) { if (pcb == NULL) Index: trunk/src/layer_ui.c =================================================================== --- trunk/src/layer_ui.c (revision 34218) +++ trunk/src/layer_ui.c (revision 34219) @@ -31,15 +31,18 @@ /* Virtual layers for UI and debug */ #include "config.h" #include "board.h" +#include "data.h" #include "layer.h" #include "event.h" #include #include "genvector/vtp0.h" +#include "genht/hash.h" #include "layer_ui.h" vtp0_t pcb_uilayers; +pcb_data_t *pcb_uilayer_dummy_data; +static pcb_data_t pcb_uilayer_dummy_data_; - pcb_layer_t *pcb_uilayer_alloc(const char *cookie, const char *name, const rnd_color_t *color) { int n; @@ -103,9 +106,16 @@ rnd_event(&PCB->hidlib, PCB_EVENT_LAYERS_CHANGED, NULL); } +void pcb_uilayer_init(void) +{ + pcb_uilayer_dummy_data = &pcb_uilayer_dummy_data_; + htip_init(&pcb_uilayer_dummy_data->id2obj, longhash, longkeyeq); +} + void pcb_uilayer_uninit(void) { vtp0_uninit(&pcb_uilayers); + htip_uninit(&pcb_uilayer_dummy_data->id2obj); } pcb_layer_t *pcb_uilayer_get(long ui_ly_id) Index: trunk/src/layer_ui.h =================================================================== --- trunk/src/layer_ui.h (revision 34218) +++ trunk/src/layer_ui.h (revision 34219) @@ -35,13 +35,17 @@ #include #include "genvector/vtp0.h" +#include "genht/htip.h" /* list of all UI layers - each item is a persistent pointer to a layer struct */ extern vtp0_t pcb_uilayers; +extern pcb_data_t *pcb_uilayer_dummy_data; + pcb_layer_t *pcb_uilayer_alloc(const char *cookie, const char *name, const rnd_color_t *color); void pcb_uilayer_free(pcb_layer_t *l); void pcb_uilayer_free_all_cookie(const char *cookie); +void pcb_uilayer_init(void); void pcb_uilayer_uninit(void); pcb_layer_t *pcb_uilayer_get(long ui_ly_id); Index: trunk/src/main.c =================================================================== --- trunk/src/main.c (revision 34218) +++ trunk/src/main.c (revision 34219) @@ -448,6 +448,7 @@ rnd_conf_set(RND_CFR_INTERNAL, "rc/path/exec_prefix", -1, exec_prefix, RND_POL_OVERWRITE); free(exec_prefix); + pcb_uilayer_init(); pcb_layer_vis_init(); pcb_draw_init(); pcb_brave_init(); Index: trunk/src/obj_arc.c =================================================================== --- trunk/src/obj_arc.c (revision 34218) +++ trunk/src/obj_arc.c (revision 34219) @@ -51,6 +51,8 @@ #include "obj_arc_draw.h" +TODO("ui_layer parent fix: remove this"); +#include "layer_ui.h" static int pcb_arc_end_addr = 1; int *pcb_arc_start_ptr = NULL, *pcb_arc_end_ptr = &pcb_arc_end_addr; @@ -60,10 +62,9 @@ arclist_append(&layer->Arc, arc); PCB_SET_PARENT(arc, layer, layer); - if (layer->parent_type == PCB_PARENT_UI) - return; - - if (layer->parent_type == PCB_PARENT_DATA) + if (pcb_is_uilayer(layer)) + pcb_obj_id_reg(pcb_uilayer_dummy_data, arc); + else if (layer->parent_type == PCB_PARENT_DATA) pcb_obj_id_reg(layer->parent.data, arc); } @@ -72,7 +73,10 @@ pcb_layer_t *layer = arc->parent.layer; assert(arc->parent_type == PCB_PARENT_LAYER); arclist_remove(arc); - if (layer->parent_type != PCB_PARENT_UI) { + if (pcb_is_uilayer(layer)) { + pcb_obj_id_del(pcb_uilayer_dummy_data, arc); + } + else { assert(layer->parent_type == PCB_PARENT_DATA); pcb_obj_id_del(layer->parent.data, arc); } Index: trunk/src/obj_gfx.c =================================================================== --- trunk/src/obj_gfx.c (revision 34218) +++ trunk/src/obj_gfx.c (revision 34219) @@ -54,6 +54,8 @@ #include "draw.h" #include "obj_gfx_draw.h" +TODO("ui_layer parent fix: remove this"); +#include "layer_ui.h" void pcb_gfx_reg(pcb_layer_t *layer, pcb_gfx_t *gfx) { @@ -60,10 +62,9 @@ gfxlist_append(&layer->Gfx, gfx); PCB_SET_PARENT(gfx, layer, layer); - if (layer->parent_type == PCB_PARENT_UI) - return; - - if (layer->parent_type == PCB_PARENT_DATA) + if (pcb_is_uilayer(layer)) + pcb_obj_id_reg(pcb_uilayer_dummy_data, gfx); + else if (layer->parent_type == PCB_PARENT_DATA) pcb_obj_id_reg(layer->parent.data, gfx); } @@ -72,7 +73,10 @@ pcb_layer_t *layer = gfx->parent.layer; assert(gfx->parent_type == PCB_PARENT_LAYER); gfxlist_remove(gfx); - if (layer->parent_type != PCB_PARENT_UI) { + if (pcb_is_uilayer(layer)) { + pcb_obj_id_del(pcb_uilayer_dummy_data, gfx); + } + else { assert(layer->parent_type == PCB_PARENT_DATA); pcb_obj_id_del(layer->parent.data, gfx); } Index: trunk/src/obj_line.c =================================================================== --- trunk/src/obj_line.c (revision 34218) +++ trunk/src/obj_line.c (revision 34219) @@ -59,6 +59,8 @@ TODO("padstack: remove this when via is removed and the padstack is created from style directly") #include "src_plugins/lib_compat_help/pstk_compat.h" +TODO("ui_layer parent fix: remove this"); +#include "layer_ui.h" /**** allocation ****/ @@ -67,8 +69,11 @@ linelist_append(&layer->Line, line); PCB_SET_PARENT(line, layer, layer); - if (layer->parent_type == PCB_PARENT_UI) - return; + if (pcb_is_uilayer(layer)) { + pcb_obj_id_reg(pcb_uilayer_dummy_data, line); + pcb_obj_id_reg(pcb_uilayer_dummy_data, &line->Point1); + pcb_obj_id_reg(pcb_uilayer_dummy_data, &line->Point2); + } if (layer->parent_type == PCB_PARENT_DATA) { pcb_obj_id_reg(layer->parent.data, line); @@ -82,7 +87,12 @@ pcb_layer_t *layer = line->parent.layer; assert(line->parent_type == PCB_PARENT_LAYER); linelist_remove(line); - if (layer->parent_type != PCB_PARENT_UI) { + if (pcb_is_uilayer(layer)) { + pcb_obj_id_del(pcb_uilayer_dummy_data, line); + pcb_obj_id_del(pcb_uilayer_dummy_data, &line->Point1); + pcb_obj_id_del(pcb_uilayer_dummy_data, &line->Point2); + } + else { assert(layer->parent_type == PCB_PARENT_DATA); pcb_obj_id_del(layer->parent.data, line); pcb_obj_id_del(layer->parent.data, &line->Point1); Index: trunk/src/obj_poly.c =================================================================== --- trunk/src/obj_poly.c (revision 34218) +++ trunk/src/obj_poly.c (revision 34219) @@ -59,6 +59,9 @@ #include "obj_poly_draw_helper.c" +TODO("ui_layer parent fix: remove this"); +#include "layer_ui.h" + /*** allocation ***/ void pcb_poly_reg(pcb_layer_t *layer, pcb_poly_t *poly) @@ -66,10 +69,9 @@ polylist_append(&layer->Polygon, poly); PCB_SET_PARENT(poly, layer, layer); - if (layer->parent_type == PCB_PARENT_UI) - return; - - if (layer->parent_type == PCB_PARENT_DATA) + if (pcb_is_uilayer(layer)) + pcb_obj_id_reg(pcb_uilayer_dummy_data, poly); + else if (layer->parent_type == PCB_PARENT_DATA) pcb_obj_id_reg(layer->parent.data, poly); } @@ -80,7 +82,10 @@ pcb_term_del_auto((pcb_any_obj_t *)poly); assert(poly->parent_type == PCB_PARENT_LAYER); polylist_remove(poly); - if (layer->parent_type != PCB_PARENT_UI) { + if (pcb_is_uilayer(layer)) { + pcb_obj_id_del(pcb_uilayer_dummy_data, poly); + } + else { assert(layer->parent_type == PCB_PARENT_DATA); pcb_obj_id_del(layer->parent.data, poly); } Index: trunk/src/obj_text.c =================================================================== --- trunk/src/obj_text.c (revision 34218) +++ trunk/src/obj_text.c (revision 34219) @@ -55,6 +55,9 @@ #include "obj_text_draw.h" #include "conf_core.h" +TODO("ui_layer parent fix: remove this"); +#include "layer_ui.h" + /*** allocation ***/ void pcb_text_reg(pcb_layer_t *layer, pcb_text_t *text) @@ -62,10 +65,9 @@ textlist_append(&layer->Text, text); PCB_SET_PARENT(text, layer, layer); - if (layer->parent_type == PCB_PARENT_UI) - return; - - if (layer->parent_type == PCB_PARENT_DATA) + if (pcb_is_uilayer(layer)) + pcb_obj_id_reg(pcb_uilayer_dummy_data, text); + else if (layer->parent_type == PCB_PARENT_DATA) pcb_obj_id_reg(layer->parent.data, text); } @@ -74,7 +76,9 @@ pcb_layer_t *layer = text->parent.layer; assert(text->parent_type == PCB_PARENT_LAYER); textlist_remove(text); - if (layer->parent_type != PCB_PARENT_UI) { + if (pcb_is_uilayer(layer)) { + pcb_obj_id_del(pcb_uilayer_dummy_data, text); + } else { assert(layer->parent_type == PCB_PARENT_DATA); pcb_obj_id_del(layer->parent.data, text); } Index: trunk/src/remove_act.c =================================================================== --- trunk/src/remove_act.c (revision 34218) +++ trunk/src/remove_act.c (revision 34219) @@ -38,6 +38,7 @@ #include #include "remove.h" #include "board.h" +#include "layer_ui.h" #include "funchash_core.h" #define PCB (do_not_use_PCB) @@ -72,7 +73,10 @@ RND_ACT_IRES(-1); return 0; } - pcb_remove_object(obj->type, obj->parent.any, obj, obj); + if ((obj->parent_type == PCB_PARENT_LAYER) && (pcb_is_uilayer(obj->parent.layer))) + pcb_destroy_object(NULL, obj->type, obj->parent.any, obj, obj); /* no undo */ + else + pcb_remove_object(obj->type, obj->parent.any, obj, obj); } else { /* interactive remove */ rnd_hidlib_t *hidlib = RND_ACT_HIDLIB;