From fec6719a2b7ac48372d8d44098a3b2938948fd2e Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 14 Nov 2022 22:21:49 +0000 Subject: [PATCH] Fix duplicate call to term_resize_request_completed(). A KDE user observed that if you 'dock' a GTK PuTTY window to the side of the screen (by dragging it to the RH edge, causing it to half-maximise over the right-hand half of the display, similarly to Windows), and then send a terminal resize sequence, then PuTTY fails the assertion in term_resize_request_completed() which expects that an unacknowledged resize request was currently in flight. When drawing_area_setup() calls term_resize_request_completed() in response to the inst->term_resize_notification_required flag, it resets the inst->win_resize_pending flag, but doesn't reset inst->term_resize_notification_required. As a result, the _next_ call to drawing_area_setup will find that flag still set, and make a duplicate call to term_resize_request_completed, after the terminal no longer believes it's waiting for a response to a resize request. And in this 'docked to the right-hand side of the display' state, KDE apparently triggers two calls to drawing_area_setup() in quick succession, making this bug manifest. I could fix this by clearing inst->term_resize_notification_required. But inspecting all the other call sites, it seems clear to me that my original intention was for inst->term_resize_notification_required to be a flag that's only meaningful if inst->win_resize_pending is set. So I think a better fix is to conditionalise the check in drawing_area_setup so that we don't even check inst->term_resize_notification_required if !inst->win_resize_pending. --- unix/window.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/unix/window.c b/unix/window.c index 5460bb52..2439fd01 100644 --- a/unix/window.c +++ b/unix/window.c @@ -788,10 +788,11 @@ static void drawing_area_setup(GtkFrontend *inst, int width, int height) inst->drawing_area_setup_called = true; if (inst->term) term_size(inst->term, h, w, conf_get_int(inst->conf, CONF_savelines)); - if (inst->term_resize_notification_required) - term_resize_request_completed(inst->term); - if (inst->win_resize_pending) + if (inst->win_resize_pending) { + if (inst->term_resize_notification_required) + term_resize_request_completed(inst->term); inst->win_resize_pending = false; + } if (!inst->drawing_area_setup_needed) return;