Re: Crashes with long words in strings passed to gtk_widget_set_tooltip_text()



Emmanuel Thomas-Maurin <manutm007 gmail com> wrote:

> On 04/20/2011 09:42 PM, Fabian Keil wrote:
> > I think even not showing a tooltip at all, or replacing the
> > text provided by the application with something like
> > "tooltip doesn't fit screen" would be a behaviour that is
> > vastly superior to crashing and less surprising for developers
> > that are reading the GTK documentation but aren't familiar
> > with the actual code.
> 
> I've been searching a little bit in the source code for the GDK warning:
> "Native Windows wider or taller than 65535 pixels are not supported".
> It appears (in gdkwindow-x11.c and gdkgeometry-x11.c) that, in case
> width or height is > 65535, then it's set to 65535. But (if I'm right),
> as supported width / height go down to 32767 for X, the app get a GDK
> error and crashes anyways. Maybe setting the width / height limit to
> 32767 in GDK could fix that.

The attached patch limits the width and height to 16384
and prevents the crashes for me. I previously tried both
32767 and 32767-1 but still got the crashes.

I didn't try anything between 16384 and 32767-1 so the
actual limit may be higher (and not connected to 2**n).

> BTW, have you file a bug for the issue? It's the best way to have it fixed.

I haven't filed a bug report yet as it wasn't clear to me
if the behaviour is actually considered a bug. If there's
an agreement that the behaviour is a bug, I wouldn't mind
filing one.

Fabian
From 4620a5e9bcd25eafe62936393d72487f3adeeb03 Mon Sep 17 00:00:00 2001
From: Fabian Keil <fk fabiankeil de>
Date: Thu, 21 Apr 2011 13:52:12 +0200
Subject: [PATCH] Limit the width and height in _gdk_window_impl_new() to 16384 instead of 65535.

The latter limit is too high to prevent crashes later on.
---
 gdk/x11/gdkwindow-x11.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 175adb6..4bc2257 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -665,6 +665,7 @@ _gdk_window_impl_new (GdkWindow     *window,
   unsigned int class;
   const char *title;
   int i;
+  static const height_and_width_limit = 16384;
   
   private = (GdkWindowObject *) window;
   
@@ -776,15 +777,16 @@ _gdk_window_impl_new (GdkWindow     *window,
       g_object_ref (draw_impl->colormap);
     }
 
-  if (private->width > 65535 ||
-      private->height > 65535)
+  if (private->width > height_and_width_limit ||
+      private->height > height_and_width_limit)
     {
-      g_warning ("Native Windows wider or taller than 65535 pixels are not supported");
+      g_warning ("Native Windows wider or taller than %d pixels are not supported",
+                 height_and_width_limit);
       
-      if (private->width > 65535)
-	private->width = 65535;
-      if (private->height > 65535)
-	private->height = 65535;
+      if (private->width > height_and_width_limit)
+	private->width = height_and_width_limit;
+      if (private->height > height_and_width_limit)
+	private->height = height_and_width_limit;
     }
   
   xid = draw_impl->xid = XCreateWindow (xdisplay, xparent,
-- 
1.7.4.1

Attachment: signature.asc
Description: PGP signature



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