From c1ceaa9868a4b1686b17d08060be32479fa67d12 Mon Sep 17 00:00:00 2001 From: Michael James Gratton Date: Fri, 27 Jan 2017 14:43:05 +1100 Subject: [PATCH] Clamp ConversationWebView height again to avoid crashes displaying large images. --- .../conversation-viewer/conversation-web-view.vala | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/client/conversation-viewer/conversation-web-view.vala b/src/client/conversation-viewer/conversation-web-view.vala index ffbdac80..aac2686f 100644 --- a/src/client/conversation-viewer/conversation-web-view.vala +++ b/src/client/conversation-viewer/conversation-web-view.vala @@ -85,7 +85,17 @@ public class ConversationWebView : ClientWebView { // doesn't seem to work. public override void get_preferred_height(out int minimum_height, out int natural_height) { - minimum_height = natural_height = this.preferred_height; + // XXX clamp height to something not too outrageous so we + // don't get an XServer error trying to allocate a massive + // window. + const uint max_pixels = 8 * 1024 * 1024; + int width = get_allocated_width(); + int height = this.preferred_height; + if (height * width > max_pixels) { + height = (int) Math.floor(max_pixels / (double) width); + } + + minimum_height = natural_height = height; } // Overridden since we always what the view to be sized according