This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gui][PATCH] Clamp width and height values in setNativeBounds
- From: Thomas Fitzsimmons <fitzsim at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Wed, 26 May 2004 22:47:13 -0400
- Subject: [gui][PATCH] Clamp width and height values in setNativeBounds
Hi,
I committed this patch to java-gui-branch. It eliminates GTK assertion
failures when an attempt is made to set a Component's width or height to
a value less than zero.
Tom
2004-05-26 Thomas Fitzsimmons <fitzsim@redhat.com>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
(setNativeBounds): Clamp width and height values to >= 0.
Index: jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c,v
retrieving revision 1.15.2.10
diff -u -r1.15.2.10 gnu_java_awt_peer_gtk_GtkComponentPeer.c
--- jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c 27 May 2004 02:23:41 -0000 1.15.2.10
+++ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c 27 May 2004 02:37:33 -0000
@@ -725,10 +725,14 @@
gdk_threads_enter ();
widget = GTK_WIDGET (ptr);
+
+ /* We assume that -1 is a width or height and not a request for the
+ widget's natural size. */
+ width = width < 0 ? 0 : width;
+ height = height < 0 ? 0 : height;
+
if (GTK_IS_VIEWPORT (widget->parent))
- {
- gtk_widget_set_size_request (widget, width, height);
- }
+ gtk_widget_set_size_request (widget, width, height);
else
{
gtk_widget_set_size_request (widget, width, height);