[geary/wip/728002-webkit2] Clamp ConversationWebView height again to avoid crashes displaying large images.



commit aa9a10ebd6c8a1ac8da91c88b64e721c3cc38479
Author: Michael James Gratton <mike vee net>
Date:   Fri Jan 27 14:43:05 2017 +1100

    Clamp ConversationWebView height again to avoid crashes displaying large images.

 .../conversation-viewer/conversation-web-view.vala |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-web-view.vala 
b/src/client/conversation-viewer/conversation-web-view.vala
index ffbdac8..aac2686 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]