From cdcec25959e82297a2af58073084d45f353aefb7 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 23 Dec 2013 21:24:25 +0200 Subject: [PATCH] Last portion of fix for bug #16051 with redisplay loops. src/xdisp.c (redisplay_tool_bar): Modify the tool-bar-lines frame parameter only when the new size is different from the old one, and the new size can be achieved given the frame height. --- src/ChangeLog | 3 +++ src/xdisp.c | 37 +++++++++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index e1df65bbfe8..818ff2784be 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -5,6 +5,9 @@ redisplay_tool_bar does. Improve and fix commentary. (hscroll_window_tree): Don't assume w->cursor.vpos is within the limits of the glyph matrices. (Bug#16051) + (redisplay_tool_bar): Modify the tool-bar-lines frame parameter + only when the new size is different from the old one, and the new + size can be achieved given the frame height. 2013-12-23 Jan Djärv diff --git a/src/xdisp.c b/src/xdisp.c index 9a3c27fc6ae..1c157c7be0a 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -12289,18 +12289,35 @@ redisplay_tool_bar (struct frame *f) if (change_height_p) { + /* Current size of the tool-bar window in canonical line + units. */ + int old_lines = WINDOW_TOTAL_LINES (w); + /* Required size of the tool-bar window in canonical + line units. */ int new_lines = ((new_height + FRAME_LINE_HEIGHT (f) - 1) / FRAME_LINE_HEIGHT (f)); - - XSETFRAME (frame, f); - Fmodify_frame_parameters (frame, - list1 (Fcons (Qtool_bar_lines, - make_number (new_lines)))); - /* Always do that now. */ - clear_glyph_matrix (w->desired_matrix); - f->n_tool_bar_rows = nrows; - f->fonts_changed = 1; - return 1; + /* Maximum size of the tool-bar window in canonical line + units that this frame can allow. */ + int max_lines = + WINDOW_TOTAL_LINES (XWINDOW (FRAME_ROOT_WINDOW (f))) - 1; + + /* Don't try to change the tool-bar window size and set + the fonts_changed flag unless really necessary. That + flag causes redisplay to give up and retry + redisplaying the frame from scratch, so setting it + unnecessarily can lead to nasty redisplay loops. */ + if (new_lines <= max_lines + && eabs (new_lines - old_lines) >= 1) + { + XSETFRAME (frame, f); + Fmodify_frame_parameters (frame, + list1 (Fcons (Qtool_bar_lines, + make_number (new_lines)))); + clear_glyph_matrix (w->desired_matrix); + f->n_tool_bar_rows = nrows; + f->fonts_changed = 1; + return 1; + } } } } -- 2.39.2