From 29cb7e40eb5e0a5bf33b4d6281f513a465231d41 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 3 Jun 2019 19:05:00 +0100 Subject: [PATCH] GTK: fix handling of delete event in Change Settings dialog. If the user closes the Change Settings dialog box using the close button provided by the window manager (or some analogous thing that generates the same X11 event) instead of using the Cancel button within the dialog itself, then after_change_settings_dialog() gets called with retval < 0, which triggers an early return path in which we forget to call unregister_dialog(), and as a result, assertions fail all over the place the _next_ time you try to put up a Change Settings dialog. Also, the early return causes ctx.newconf to be memory-leaked. So rather than just moving the unregister_dialog() call to above the early return, a better fix is to remove the early return completely, and simply treat retval<0 the same as retval==0: it doesn't matter _how_ the user closed the config box without committing the changes, it only matters that they did. --- unix/gtkwin.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/unix/gtkwin.c b/unix/gtkwin.c index 5ab06e90..15598bf0 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -4635,18 +4635,11 @@ static void after_change_settings_dialog(void *vctx, int retval) sfree(vctx); /* we've copied this already */ - if (retval < 0) { - /* If the dialog box was aborted without giving a result - * (probably because the whole session window closed), we have - * nothing further to do. */ - return; - } - assert(lenof(ww) == NCFGCOLOURS); unregister_dialog(&inst->seat, DIALOG_SLOT_RECONFIGURE); - if (retval) { + if (retval > 0) { inst->conf = newconf; /* Pass new config data to the logging module */