Index: dlg.c =================================================================== --- dlg.c (revision 31684) +++ 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: drc_query.c =================================================================== --- drc_query.c (revision 31684) +++ 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;