Index: pcb-mincut/main.c =================================================================== --- pcb-mincut/main.c (revision 28012) +++ pcb-mincut/main.c (revision 28013) @@ -16,7 +16,7 @@ { int *best; gr_t *g; - int n; + int n, cancel; g = load(stdin); if (g == NULL) { @@ -23,7 +23,7 @@ fprintf(stderr, "Failed to load input, exiting\n"); exit(1); } - best = solve(g, NULL); + best = solve(g, NULL, &cancel); for(n = 0; best[n*2] != -1; n++) printf("%s-%s\n", strempty(g->node2name[best[n*2+0]]), strempty(g->node2name[best[n*2+1]])); Index: pcb-mincut/solve.c =================================================================== --- pcb-mincut/solve.c (revision 28012) +++ pcb-mincut/solve.c (revision 28013) @@ -207,7 +207,7 @@ } #define strempty(s) ((s) == NULL ? "" : (s)) -int *solve(gr_t *g, int (*progress)(long so_far, long total, const char *msg)) +int *solve(gr_t *g, int (*progress)(long so_far, long total, const char *msg), int *cancel) { int n, best, res, till, cuts_size, have_progress = 0; double nd; @@ -236,8 +236,10 @@ currt = time(NULL); if (currt >= nextt) { have_progress = 1; - if (progress(n, till, "Optimizing shortcircuit indication\nusing mincut... Press cancel\nto get a dumb indication")) + if (progress(n, till, "Optimizing shortcircuit indication\nusing mincut... Press cancel\nto get a dumb indication")) { + *cancel = 1; break; + } nextt = currt+1; } } Index: pcb-mincut/solve.h =================================================================== --- pcb-mincut/solve.h (revision 28012) +++ pcb-mincut/solve.h (revision 28013) @@ -2,4 +2,4 @@ /* returns a list of object ID pairs (each nth and n+1th element) terminated by a -1;-1. Cutting these vertices would separate g. */ -int *solve(gr_t *g, int (*progress)(long so_far, long total, const char *msg)); +int *solve(gr_t *g, int (*progress)(long so_far, long total, const char *msg), int *cancel); Index: rats_mincut.c =================================================================== --- rats_mincut.c (revision 28012) +++ rats_mincut.c (revision 28013) @@ -109,7 +109,7 @@ } /* returns 0 on succes */ -static int proc_short(pcb_any_obj_t *term, pcb_net_t *Snet, pcb_net_t *Tnet) +static int proc_short(pcb_any_obj_t *term, pcb_net_t *Snet, pcb_net_t *Tnet, int *cancel) { pcb_coord_t x, y; short_conn_t *n, **lut_by_oid, **lut_by_gid, *next; @@ -282,7 +282,9 @@ #endif if (!bad_gr) { - solution = solve(g, pcb_hid_progress); + solution = solve(g, pcb_hid_progress, cancel); + if (cancel) + return 1; if (solution != NULL) { debprintf("Would cut:\n"); @@ -326,6 +328,7 @@ int *handled; pcb_any_obj_t *term; pcb_net_t *Snet, *Tnet; + int cancel = 0; if (!conf_mincut.plugins.mincut.enable) return; @@ -351,7 +354,7 @@ return; Tnet = (pcb_net_t *)argv[3].d.p; - if (proc_short(term, Snet, Tnet) == 0) + if (proc_short(term, Snet, Tnet, &cancel) == 0) *handled = 1; }