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



commit a6acfe97d443aa2254c6481ecad27c3f14240bc7
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 da4606e..78ab4fe 100644
--- a/src/client/conversation-viewer/conversation-web-view.vala
+++ b/src/client/conversation-viewer/conversation-web-view.vala
@@ -78,6 +78,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]