[geary/wip/765516-gtk-widget-conversation-viewer: 129/142] (Re-)fix crash when displaying exceptionally large messages.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/765516-gtk-widget-conversation-viewer: 129/142] (Re-)fix crash when displaying exceptionally large messages.
- Date: Fri, 2 Sep 2016 04:36:28 +0000 (UTC)
commit 5bfc56f49956ce704e7bc3d10debaedd3dbd2516
Author: Michael James Gratton <mike vee net>
Date: Wed Aug 17 22:21:26 2016 +1000
(Re-)fix crash when displaying exceptionally large messages.
* src/client/conversation-viewer/conversation-web-view.vala: Go back to
clamping the window height until some better solution is found.
.../conversation-viewer/conversation-web-view.vala | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-web-view.vala
b/src/client/conversation-viewer/conversation-web-view.vala
index 72f2ae5..756f405 100644
--- a/src/client/conversation-viewer/conversation-web-view.vala
+++ b/src/client/conversation-viewer/conversation-web-view.vala
@@ -87,14 +87,24 @@ public class ConversationWebView : StylishWebView {
base.get_preferred_height(out minimum_height, out natural_height);
WebKit.DOM.Element html = get_dom_document().get_document_element();
- int offset_height = (int) html.offset_height;
- int offset_width = (int) html.offset_width;
+ long offset_height = html.offset_height;
+ long offset_width = html.offset_width;
+ long px = offset_width * offset_height;
+
+ const long MAX_LEN = 15 * 1000;
+ const long MAX_PX = 10 * 1000 * 1000;
// If the offset_width is very small, the offset_height will
// likely be bogus, so just pretend we have no height for the
// moment. WebKitGTK seems to report an offset width of 1 in
// these cases.
if (offset_width > 1) {
+ if (offset_height > MAX_LEN || px > MAX_PX) {
+ long new_height = long.min(MAX_LEN, MAX_PX / offset_width);
+ debug("Clamping window height to: %lu, current size: %lux%lu (%lupx)",
+ new_height, offset_width, offset_height, px);
+ offset_height = new_height;
+ }
// Avoid multiple notify signals?
if (!this.is_height_valid) {
this.is_height_valid = true;
@@ -103,7 +113,7 @@ public class ConversationWebView : StylishWebView {
offset_height = 0;
}
- minimum_height = natural_height = offset_height;
+ minimum_height = natural_height = (int) offset_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]