[geary/wip/765516-gtk-widget-conversation-viewer: 35/80] Add a workaround for web_view X allocation error.



commit eeba0f8c4b7770df1d2c99907089a80c541c038d
Author: Michael James Gratton <mike vee net>
Date:   Tue Apr 12 21:56:44 2016 +1000

    Add a workaround for web_view X allocation error.
    
    * src/client/conversation-viewer/conversation-web-view.vala
      (ConversationWebView::get_preferred_height): Clamp reported preferred
      height to something reasonable to avoid trying to allocate a stupidly
      big pixmap.

 .../conversation-viewer/conversation-web-view.vala |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-web-view.vala 
b/src/client/conversation-viewer/conversation-web-view.vala
index 69bd762..a529422 100644
--- a/src/client/conversation-viewer/conversation-web-view.vala
+++ b/src/client/conversation-viewer/conversation-web-view.vala
@@ -68,6 +68,19 @@ public class ConversationWebView : StylishWebView {
         if (load_status == WebKit.LoadStatus.FINISHED) {
             preferred_height = (int) get_dom_document().get_body().offset_height;
         }
+
+        // XXX Currently, for some messages the WebView will report
+        // very large offset heights, causing GDK and X allocation
+        // failures/warnings. If we get one, log it and limit it.  A
+        // value of ~22000 was crashing my xserver with a WebView
+        // width of around 745.
+        const int MAX = 10000;
+        if (preferred_height > MAX) {
+            warning("WebView height reported as %i/%li, clamping",
+                    preferred_height,
+                    get_dom_document().get_body().offset_height);
+            preferred_height = MAX;
+        }
         minimum_height = natural_height = preferred_height;
     }
 


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