Index: trunk/src/find_drc.c =================================================================== --- trunk/src/find_drc.c (revision 21228) +++ trunk/src/find_drc.c (revision 21229) @@ -41,22 +41,13 @@ static void GotoError(void); static pcb_bool DRCFind(pcb_view_list_t *lst, int What, void *ptr1, void *ptr2, void *ptr3); -static unsigned long int pcb_drc_next_uid = 0; - static pcb_view_t *pcb_drc_violation_new( const char *type, const char *title, const char *explanation, pcb_bool have_measured, pcb_coord_t measured_value, pcb_coord_t required_value, pcb_idpath_list_t objs[2]) { - pcb_view_t *violation = calloc(sizeof(pcb_view_t), 1); + pcb_view_t *violation = pcb_view_new(type, title, explanation); - pcb_drc_next_uid++; - violation->uid = pcb_drc_next_uid; - - violation->type = pcb_strdup(type); - violation->title = pcb_strdup(title); - violation->explanation = pcb_strdup(explanation); - violation->data_type = PCB_VIEW_DRC; violation->data.drc.have_measured = have_measured; violation->data.drc.measured_value = measured_value; Index: trunk/src/view.c =================================================================== --- trunk/src/view.c (revision 21228) +++ trunk/src/view.c (revision 21229) @@ -36,9 +36,10 @@ #undef TDL_DONT_UNDEF #include - #include "actions.h" +#include "compat_misc.h" +static unsigned long int pcb_view_next_uid = 0; void pcb_view_free(pcb_view_t *item) { @@ -90,3 +91,21 @@ } } +pcb_view_t *pcb_view_new(const char *type, const char *title, const char *explanation) +{ + pcb_view_t *v = calloc(sizeof(pcb_view_t), 1); + + pcb_view_next_uid++; + v->uid = pcb_view_next_uid; + + if (type == NULL) type = ""; + if (title == NULL) title = ""; + if (explanation == NULL) explanation = ""; + + v->type = pcb_strdup(type); + v->title = pcb_strdup(title); + v->explanation = pcb_strdup(explanation); + + return v; +} + Index: trunk/src/view.h =================================================================== --- trunk/src/view.h (revision 21228) +++ trunk/src/view.h (revision 21229) @@ -99,6 +99,8 @@ /* Zoom the drawing area to the drc error */ void pcb_view_goto(pcb_view_t *item); +/* Allocate a new, floating (unlinked) view with no data or bbox */ +pcb_view_t *pcb_view_new(const char *type, const char *title, const char *explanation); /*** temporary, until moved out to a plugin ***/ int pcb_drc_all(pcb_view_list_t *lst);