Index: trunk/src_plugins/drc_query/dlg.c =================================================================== --- trunk/src_plugins/drc_query/dlg.c (revision 31684) +++ trunk/src_plugins/drc_query/dlg.c (revision 31685) @@ -44,6 +44,8 @@ static void drc_query_progress_close_cb(void *caller_data, rnd_hid_attr_ev_t ev) { progbar_t *pb = caller_data; + if (!pb->force_close) + pb->prog->cancel = 1; pb->prog->dialog = NULL; if (!pb->force_close) { RND_DAD_FREE(pb->dlg); @@ -84,7 +86,7 @@ RND_DAD_NEW("drc_query_progress", pb->dlg, "drc_query: DRC progress", pb, rnd_true, drc_query_progress_close_cb); } -static void drc_query_progress(pcb_qry_exec_t *ec, long at, long total) +static int drc_query_progress(pcb_qry_exec_t *ec, long at, long total) { drc_query_prog_t *prog = ec->progress_ctx; progbar_t *pb = prog->dialog; @@ -97,17 +99,17 @@ fprintf(stderr, " Violations: %ld\n", prog->qctx->hit_cnt); else fprintf(stderr, "\n"); - return; + return prog->cancel; } if (total < 0) { if (prog->dialog == NULL) - return; + return 0; prog->dialog = NULL; pb->force_close = 1; RND_DAD_FREE(pb->dlg); free(pb); - return; + return 0; } if (prog->dialog == NULL) { @@ -134,6 +136,7 @@ } rnd_hid_iterate(rnd_gui); + return prog->cancel; } Index: trunk/src_plugins/drc_query/drc_query.c =================================================================== --- trunk/src_plugins/drc_query/drc_query.c (revision 31684) +++ trunk/src_plugins/drc_query/drc_query.c (revision 31685) @@ -149,6 +149,7 @@ long script_total, script_at; void *dialog; drc_qry_ctx_t *qctx; + unsigned cancel:1; } drc_query_prog_t; static long drc_qry_exec(pcb_qry_exec_t *ec, pcb_board_t *pcb, pcb_view_list_t *lst, const char *name, const char *type, const char *title, const char *desc, const char *query) @@ -159,6 +160,9 @@ pcb_drcq_stat_t *st; double ts, te; + if ((prog != 0) && (prog->cancel)) + return 0; + if (query == NULL) { rnd_message(RND_MSG_ERROR, "drc_query: igoring rule with no query string:%s\n", name); return 0; @@ -215,7 +219,7 @@ } -static void drc_query_progress(pcb_qry_exec_t *ec, long at, long total); +static int drc_query_progress(pcb_qry_exec_t *ec, long at, long total); static void pcb_drc_query(rnd_hidlib_t *hidlib, void *user_data, int argc, rnd_event_arg_t argv[]) { @@ -237,6 +241,7 @@ prog.script_total = rnd_conflist_length(&conf_drc_query.plugins.drc_query.rules); prog.script_at = 0; prog.dialog = NULL; + prog.cancel = 0; rnd_conflist_foreach(&conf_drc_query.plugins.drc_query.rules, &it, i) { lht_node_t *rule = i->prop.src; Index: trunk/src_plugins/query/query_exec.c =================================================================== --- trunk/src_plugins/query/query_exec.c (revision 31684) +++ trunk/src_plugins/query/query_exec.c (revision 31685) @@ -392,9 +392,10 @@ } -#define PROGRESS_CB(ctx, at, total) \ +#define PROGRESS_CB(ctx, at, total, cancel) \ do { \ time_t now; \ + cancel = 0; \ if (ctx->progress_cb == NULL) break; \ now = time(NULL); \ if (ctx->last_prog_cb == 0) \ @@ -401,7 +402,7 @@ ctx->last_prog_cb = now; \ else if (now > ctx->last_prog_cb) { \ ctx->last_prog_cb = now; \ - ctx->progress_cb(ctx, at, total); \ + cancel = ctx->progress_cb(ctx, at, total); \ } \ } while(0) @@ -413,8 +414,12 @@ long ilen = vtp0_len(ctx->iter->vects[i]); long at = ++ctx->iter->idx[i]; if (at < ilen) { - if (i == ctx->iter->last_active) - PROGRESS_CB(ctx, at, ilen); + if (i == ctx->iter->last_active) { + int cancel; + PROGRESS_CB(ctx, at, ilen, cancel); + if (cancel) + return 0; + } return 1; } } Index: trunk/src_plugins/query/query_exec.h =================================================================== --- trunk/src_plugins/query/query_exec.h (revision 31684) +++ trunk/src_plugins/query/query_exec.h (revision 31685) @@ -43,7 +43,7 @@ pcb_query_iter_t *iter; /* current iterator */ vtp0_t autofree; - void (*progress_cb)(pcb_qry_exec_t *ec, long at, long total); + int (*progress_cb)(pcb_qry_exec_t *ec, long at, long total); void *progress_ctx; /* data/call cache */