Index: trunk/src/hid_dad.h =================================================================== --- trunk/src/hid_dad.h (revision 25272) +++ trunk/src/hid_dad.h (revision 25273) @@ -99,9 +99,11 @@ #define PCB_DAD_RUN(table) pcb_hid_dad_run(table ## _hid_ctx, table ## _ret_override) -/* failed is non-zero on cancel */ +/* failed is zero on success and -1 on error (e.g. cancel) or an arbitrary + value set by ret_override (e.g. on close buttons) */ #define PCB_DAD_AUTORUN(id, table, title, caller_data, failed) \ do { \ + int __ok__; \ if (table ## _result == NULL) \ PCB_DAD_ALLOC_RESULT(table); \ table ## _ret_override = calloc(sizeof(pcb_dad_retovr_t), 1); \ @@ -108,7 +110,8 @@ table ## _ret_override->dont_free++; \ table ## _ret_override->valid = 0; \ table ## _append_lock = 1; \ - failed = pcb_attribute_dialog_(id,table, table ## _len, table ## _result, title, caller_data, (void **)&(table ## _ret_override), table ## _defx, table ## _defy, &table ## _hid_ctx); \ + __ok__ = pcb_attribute_dialog_(id,table, table ## _len, table ## _result, title, caller_data, (void **)&(table ## _ret_override), table ## _defx, table ## _defy, &table ## _hid_ctx); \ + failed = (__ok__ == 0) ? -1 : 0; \ if (table ## _ret_override->valid) \ failed = table ## _ret_override->value; \ table ## _ret_override->dont_free--; \ Index: trunk/src/hid_dad_spin.c =================================================================== --- trunk/src/hid_dad_spin.c (revision 25272) +++ trunk/src/hid_dad_spin.c (revision 25273) @@ -136,7 +136,7 @@ { pcb_hid_dad_buttons_t clbtn[] = {{"Cancel", -1}, {"ok", 0}, {NULL, 0}}; spin_unit_t ctx; - int dlgres; + int dlgfail; memset(&ctx, 0, sizeof(ctx)); ctx.end = end; @@ -184,8 +184,8 @@ PCB_DAD_END(ctx.dlg); PCB_DAD_END(ctx.dlg); - PCB_DAD_AUTORUN("unit", ctx.dlg, "spinbox coord unit change", &ctx, dlgres); - if ((dlgres == 0) && (ctx.valid)) { + PCB_DAD_AUTORUN("unit", ctx.dlg, "spinbox coord unit change", &ctx, dlgfail); + if ((dlgfail == 0) && (ctx.valid)) { pcb_hid_attr_val_t hv; int unum = ctx.dlg[ctx.wunit].default_val.int_value; Index: trunk/src_plugins/dialogs/dlg_layer_flags.c =================================================================== --- trunk/src_plugins/dialogs/dlg_layer_flags.c (revision 25272) +++ trunk/src_plugins/dialogs/dlg_layer_flags.c (revision 25273) @@ -37,8 +37,8 @@ fgw_error_t pcb_act_LayerPropGui(fgw_arg_t *res, int argc, fgw_arg_t *argv) { PCB_DAD_DECL(dlg) - pcb_hid_dad_buttons_t clbtn[] = {{"Cancel", 0}, {"OK", 1}, {NULL, 0}}; - int wname, wsub, wauto, ok, ar = 0; + pcb_hid_dad_buttons_t clbtn[] = {{"Cancel", 1}, {"OK", 0}, {NULL, 0}}; + int wname, wsub, wauto, failed, ar = 0; pcb_layer_t *ly; pcb_layer_id_t lid; @@ -69,9 +69,9 @@ dlg[wsub].default_val.int_value = ly->comb & PCB_LYC_SUB; dlg[wauto].default_val.int_value = ly->comb & PCB_LYC_AUTO; - PCB_DAD_AUTORUN("layer_prop", dlg, "Properties of a logical layer", NULL, ok); + PCB_DAD_AUTORUN("layer_prop", dlg, "Properties of a logical layer", NULL, failed); - if (ok) { + if (failed == 0) { pcb_layer_combining_t comb = 0; if (strcmp(ly->name, dlg[wname].default_val.str_value) != 0) { ar |= pcb_layer_rename_(ly, (char *)dlg[wname].default_val.str_value); @@ -97,9 +97,9 @@ fgw_error_t pcb_act_GroupPropGui(fgw_arg_t *res, int argc, fgw_arg_t *argv) { PCB_DAD_DECL(dlg) - pcb_hid_dad_buttons_t clbtn[] = {{"Cancel", 0}, {"OK", 1}, {NULL, 0}}; + pcb_hid_dad_buttons_t clbtn[] = {{"Cancel", 1}, {"OK", 0}, {NULL, 0}}; int wname, wtype, wpurp, wloc; - int ok, n, ar = 0, orig_type, changed = 0, omit_loc = 0, orig_loc = -1, def_loc; + int failed, n, ar = 0, orig_type, changed = 0, omit_loc = 0, orig_loc = -1, def_loc; pcb_layergrp_id_t gid; pcb_layergrp_t *g; static const char *ltypes[] = { "top", "bottom", "any intern", "global", NULL }; @@ -163,8 +163,8 @@ orig_loc = dlg[wloc].default_val.int_value; } - PCB_DAD_AUTORUN("layer_grp_prop", dlg, "Edit the properties of a layer group (physical layer)", NULL, ok); - if (ok) { + PCB_DAD_AUTORUN("layer_grp_prop", dlg, "Edit the properties of a layer group (physical layer)", NULL, failed); + if (failed == 0) { if (strcmp(g->name, dlg[wname].default_val.str_value) != 0) { ar |= pcb_layergrp_rename_(g, (char *)dlg[wname].default_val.str_value); dlg[wname].default_val.str_value = NULL; Index: trunk/src_plugins/dialogs/dlg_test.c =================================================================== --- trunk/src_plugins/dialogs/dlg_test.c (revision 25272) +++ trunk/src_plugins/dialogs/dlg_test.c (revision 25273) @@ -276,7 +276,7 @@ PCB_DAD_AUTORUN("dlg_test", ctx.dlg, "attribute dialog test", &ctx, failed); - if (failed) + if (failed != 0) pcb_message(PCB_MSG_WARNING, "Test dialog cancelled"); PCB_DAD_FREE(ctx.dlg); Index: trunk/src_plugins/propedit/propdlg.c =================================================================== --- trunk/src_plugins/propedit/propdlg.c (revision 25272) +++ trunk/src_plugins/propedit/propdlg.c (revision 25273) @@ -345,7 +345,7 @@ { PCB_DAD_DECL(dlg) propdlg_t *ctx = caller_data; - int wkey, wval, res; + int wkey, wval, failed; pcb_hid_dad_buttons_t clbtn[] = {{"Cancel", -1}, {"OK", 0}, {NULL, 0}}; PCB_DAD_BEGIN_VBOX(dlg); @@ -360,9 +360,9 @@ PCB_DAD_END(dlg); PCB_DAD_BUTTON_CLOSES(dlg, clbtn); PCB_DAD_END(dlg); - PCB_DAD_AUTORUN("propedit_add", dlg, "Propedit: add new attribute", NULL, res); + PCB_DAD_AUTORUN("propedit_add", dlg, "Propedit: add new attribute", NULL, failed); - if (res == 0) { + if (failed == 0) { char *path = pcb_strdup_printf("a/%s", dlg[wkey].default_val.str_value); pcb_propsel_set_str(&ctx->pe, path, dlg[wval].default_val.str_value); free(path);