Index: trunk/src/crosshair.h =================================================================== --- trunk/src/crosshair.h (revision 32940) +++ trunk/src/crosshair.h (revision 32941) @@ -31,7 +31,6 @@ #define PCB_CROSSHAIR_H #include "config.h" -#include #include #include #include "obj_line.h" @@ -66,8 +65,6 @@ int AttachedPolygon_pts; /* number of valid points ever seen for this poly */ pcb_attached_object_t AttachedObject; /* data of attached objects */ pcb_route_t Route; /* Calculated line route in LINE or MOVE(LINE) mode */ - vtp0_t onpoint_objs; - vtp0_t old_onpoint_objs; pcb_any_obj_t *extobj_edit; /* refers to the editobject (of an extobj) being edited */ /* list of object IDs that could have been dragged so that they can be cycled */ Index: trunk/src_plugins/ch_onpoint/ch_onpoint.c =================================================================== --- trunk/src_plugins/ch_onpoint/ch_onpoint.c (revision 32940) +++ trunk/src_plugins/ch_onpoint/ch_onpoint.c (revision 32941) @@ -34,6 +34,7 @@ #include +#include #include #include #include @@ -46,6 +47,8 @@ static const char pcb_ch_onpoint_cookie[] = "ch_onpoint plugin"; +static vtp0_t onpoint_objs, old_onpoint_objs; + struct onpoint_search_info { pcb_crosshair_t *crosshair; rnd_coord_t X; @@ -63,7 +66,7 @@ info->X, info->Y, line->Point1.X, line->Point1.Y, line->Point2.X, line->Point2.Y); #endif if ((line->Point1.X == info->X && line->Point1.Y == info->Y) || (line->Point2.X == info->X && line->Point2.Y == info->Y)) { - vtp0_append(&crosshair->onpoint_objs, line); + vtp0_append(&onpoint_objs, line); PCB_FLAG_SET(PCB_FLAG_ONPOINT, (pcb_any_obj_t *)line); pcb_line_invalidate_draw(NULL, line); return RND_R_DIR_FOUND_CONTINUE; @@ -89,7 +92,7 @@ #endif if ((close_enough(p1x, info->X) && close_enough(p1y, info->Y)) || (close_enough(p2x, info->X) && close_enough(p2y, info->Y))) { - vtp0_append(&crosshair->onpoint_objs, arc); + vtp0_append(&onpoint_objs, arc); PCB_FLAG_SET(PCB_FLAG_ONPOINT, (pcb_any_obj_t *)arc); pcb_arc_invalidate_draw(NULL, arc); return RND_R_DIR_FOUND_CONTINUE; @@ -111,9 +114,9 @@ #define op_swap(crosshair) \ do { \ - vtp0_t __tmp__ = crosshair->onpoint_objs; \ - crosshair->onpoint_objs = crosshair->old_onpoint_objs; \ - crosshair->old_onpoint_objs = __tmp__; \ + vtp0_t __tmp__ = onpoint_objs; \ + onpoint_objs = old_onpoint_objs; \ + old_onpoint_objs = __tmp__; \ } while(0) static void *onpoint_find(vtp0_t *vect, pcb_any_obj_t *obj_ptr) @@ -140,8 +143,8 @@ op_swap(crosshair); /* Do not truncate to 0 because that may free the array */ - vtp0_truncate(&crosshair->onpoint_objs, 1); - crosshair->onpoint_objs.used = 0; + vtp0_truncate(&onpoint_objs, 1); + onpoint_objs.used = 0; info.crosshair = crosshair; @@ -158,11 +161,11 @@ } /* Undraw the old objects */ - for (i = 0; i < crosshair->old_onpoint_objs.used; i++) { - pcb_any_obj_t *op = crosshair->old_onpoint_objs.array[i]; + for (i = 0; i < old_onpoint_objs.used; i++) { + pcb_any_obj_t *op = old_onpoint_objs.array[i]; /* only remove and redraw those which aren't in the new list */ - if (onpoint_find(&crosshair->onpoint_objs, op) != NULL) + if (onpoint_find(&onpoint_objs, op) != NULL) continue; PCB_FLAG_CLEAR(PCB_FLAG_ONPOINT, op); @@ -171,11 +174,11 @@ } /* draw the new objects */ - for (i = 0; i < crosshair->onpoint_objs.used; i++) { - pcb_any_obj_t *op = crosshair->onpoint_objs.array[i]; + for (i = 0; i < onpoint_objs.used; i++) { + pcb_any_obj_t *op = onpoint_objs.array[i]; /* only draw those which aren't in the old list */ - if (onpoint_find(&crosshair->old_onpoint_objs, op) != NULL) + if (onpoint_find(&old_onpoint_objs, op) != NULL) continue; draw_line_or_arc(op); redraw = rnd_true; @@ -196,6 +199,8 @@ void pplg_uninit_ch_onpoint(void) { rnd_event_unbind_allcookie(pcb_ch_onpoint_cookie); + vtp0_uninit(&onpoint_objs); + vtp0_uninit(&old_onpoint_objs); } int pplg_init_ch_onpoint(void) @@ -202,10 +207,6 @@ { RND_API_CHK_VER; - /* Initialize the onpoint data. */ - memset(&pcb_crosshair.onpoint_objs, 0, sizeof(vtp0_t)); - memset(&pcb_crosshair.old_onpoint_objs, 0, sizeof(vtp0_t)); - rnd_event_bind(PCB_EVENT_CROSSHAIR_NEW_POS, pcb_ch_onpoint, NULL, pcb_ch_onpoint_cookie); return 0;