[kaffe] CVS kaffe (robilad): Resynced with GNU classpath: AWT peer fixes

Kaffe CVS cvs-commits at kaffe.org
Mon Jul 25 09:09:18 PDT 2005


PatchSet 6766 
Date: 2005/07/25 16:03:20
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU classpath: AWT peer fixes

Members: 
	ChangeLog:1.4291->1.4292 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c:1.7->1.8 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c:1.14->1.15 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c:1.15->1.16 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c:1.3->1.4 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:1.12->1.13 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c:1.4->1.5 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c:1.5->1.6 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c:1.9->1.10 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c:1.3->1.4 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c:1.3->1.4 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c:1.5->1.6 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c:1.8->1.9 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c:1.4->1.5 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c:1.14->1.15 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c:1.3->1.4 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c:1.11->1.12 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c:1.6->1.7 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c:1.3->1.4 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c:1.5->1.6 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c:1.7->1.8 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c:1.6->1.7 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c:1.5->1.6 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c:1.7->1.8 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c:1.6->1.7 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c:1.3->1.4 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollPanePeer.c:1.3->1.4 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c:1.12->1.13 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c:1.20->1.21 
	libraries/javalib/gnu/java/awt/peer/gtk/GtkChoicePeer.java:1.6->1.7 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4291 kaffe/ChangeLog:1.4292
--- kaffe/ChangeLog:1.4291	Mon Jul 25 14:40:23 2005
+++ kaffe/ChangeLog	Mon Jul 25 16:03:20 2005
@@ -2,6 +2,49 @@
 
 	Resynced with GNU Classpath.
 
+	2005-07-11  Thomas Fitzsimmons  <fitzsim at redhat.com>
+
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c:
+        Replace occurrences of malloc with g_malloc and free with g_free.
+
+        * gnu/java/awt/peer/gtk/GtkChoicePeer.java (connectSignals): New method.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c: Move
+        gdk_threads_enter calls to start of method bodies.  Move
+        gdk_threads_leave calls to end of method definitions bodies.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkGenericPeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollPanePeer.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c: Likewise.
+        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c: Likewise.
+
+2005-07-25  Dalibor Topic  <robilad at kaffe.org>
+
+	Resynced with GNU Classpath.
+
 	2005-07-11  David Gilbert  <david.gilbert at object-refinery.com>
 
         * java/lang/IllegalAccessException.java: fixed minor API doc errors,
Index: kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
diff -u kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c:1.7 kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c:1.8
--- kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c:1.7	Mon Jul  4 00:04:00 2005
+++ kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c	Mon Jul 25 16:03:22 2005
@@ -75,11 +75,14 @@
   (JNIEnv *env, jobject self)
 {
   struct peerfont *pfont = NULL;
+
   gdk_threads_enter ();
+
   g_assert (self != NULL);
   pfont = (struct peerfont *) g_malloc0 (sizeof (struct peerfont));
   g_assert (pfont != NULL);
   NSA_SET_FONT_PTR (env, self, pfont);
+
   gdk_threads_leave ();
 }
 
@@ -91,6 +94,7 @@
   struct peerfont *pfont = NULL;
 
   gdk_threads_enter ();
+
   pfont = (struct peerfont *)NSA_DEL_FONT_PTR (env, self);
   g_assert (pfont != NULL);
   if (pfont->layout != NULL)
@@ -102,6 +106,7 @@
   if (pfont->desc != NULL)
     pango_font_description_free (pfont->desc);
   g_free (pfont);
+
   gdk_threads_leave ();
 }
 
@@ -114,11 +119,13 @@
    jobject fontRenderContext)
 {
   struct peerfont *pfont = NULL;
-  GList *items = NULL, *i = NULL;
+  GList *items = NULL;
+  GList *i = NULL;
   gchar *str = NULL;
-  int len, j;
-  double *native_extents;
-  int *native_codes;
+  int len = 0;
+  int j = 0;
+  double *native_extents = NULL;
+  int *native_codes = NULL;
   jintArray java_codes = NULL;
   jdoubleArray java_extents = NULL;
 
@@ -227,7 +234,7 @@
 {
   struct peerfont *pfont = NULL;
   jdouble *native_metrics = NULL;
-  PangoFontMetrics *pango_metrics;
+  PangoFontMetrics *pango_metrics = NULL;
 
   gdk_threads_enter();
 
@@ -329,9 +336,10 @@
   struct peerfont *pfont = NULL;
   char const *family_name = NULL;
   enum java_awt_font_style style;
-  PangoFT2FontMap *ft2_map;
+  PangoFT2FontMap *ft2_map = NULL;
 
   gdk_threads_enter ();
+
   style = (enum java_awt_font_style) style_int;
 
   g_assert (self != NULL);
Index: kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
diff -u kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c:1.14 kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c:1.15
--- kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c:1.14	Mon Jul  4 00:04:00 2005
+++ kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c	Mon Jul 25 16:03:22 2005
@@ -46,21 +46,22 @@
 GdkPoint *
 translate_points (JNIEnv *env, jintArray xpoints, jintArray ypoints, 
 		  jint npoints, jint x_offset, jint y_offset);
-static void realize_cb (GtkWidget *widget, jobject peer);
+static void realize_cb (GtkWidget *widget, jobject jgraphics);
 
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GdkGraphics_copyState
   (JNIEnv *env, jobject obj, jobject old)
 {
-  struct graphics *g, *g_old;
+  struct graphics *g = NULL;
+  struct graphics *g_old = NULL;
 
-  g = (struct graphics *) malloc (sizeof (struct graphics));
+  gdk_threads_enter ();
+
+  g = (struct graphics *) g_malloc (sizeof (struct graphics));
   g_old = (struct graphics *) NSA_GET_PTR (env, old);
 
   *g = *g_old;
 
-  gdk_threads_enter ();
-
   g->gc = gdk_gc_new (g->drawable);
   gdk_gc_copy (g->gc, g_old->gc);
 
@@ -71,56 +72,58 @@
 
   gdk_colormap_ref (g->cm);
 
-  gdk_threads_leave ();
-
   NSA_SET_PTR (env, obj, g);
+
+  gdk_threads_leave ();
 }
 
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__II
   (JNIEnv *env, jobject obj, jint width, jint height)
 {
-  struct graphics *g;
+  struct graphics *g = NULL;
 
-  g = (struct graphics *) malloc (sizeof (struct graphics));
+  gdk_threads_enter ();
+
+  g = (struct graphics *) g_malloc (sizeof (struct graphics));
   g->x_offset = g->y_offset = 0;
 
-  gdk_threads_enter ();
   g->drawable = (GdkDrawable *) gdk_pixmap_new (NULL, width, height, 
 						gdk_rgb_get_visual ()->depth);
   g->cm = gdk_rgb_get_cmap ();
   gdk_colormap_ref (g->cm);
   g->gc = gdk_gc_new (g->drawable);
 
-  gdk_threads_leave ();
-
   NSA_SET_PTR (env, obj, g);
+
+  gdk_threads_leave ();
 }
 
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GdkGraphics_initFromImage
    (JNIEnv *env, jobject obj, jobject source)
 {
-  struct graphics *g;
-  GdkPixmap *pixmap = 
-    gnu_java_awt_peer_gtk_GtkImage_getPixmap(env, source);
+  struct graphics *g = NULL;
+  GdkPixmap *pixmap = NULL;
+
+  gdk_threads_enter ();
+
+  pixmap = gnu_java_awt_peer_gtk_GtkImage_getPixmap(env, source);
   g_assert(pixmap != NULL);
   gdk_pixmap_ref (pixmap);
 
-  g = (struct graphics *) malloc (sizeof (struct graphics));
+  g = (struct graphics *) g_malloc (sizeof (struct graphics));
   g->x_offset = g->y_offset = 0;
 
-  gdk_threads_enter ();
-
   g->drawable = (GdkDrawable *)pixmap;
 
   g->cm = gdk_drawable_get_colormap (g->drawable);
   gdk_colormap_ref (g->cm);
   g->gc = gdk_gc_new (g->drawable);
 
-  gdk_threads_leave ();
-
   NSA_SET_PTR (env, obj, g);
+
+  gdk_threads_leave ();
 }
 
 /* copy the native state of the peer (GtkWidget *) to the native state
@@ -129,16 +132,18 @@
 Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2
   (JNIEnv *env, jobject obj, jobject peer)
 {
-  struct graphics *g = (struct graphics *) malloc (sizeof (struct graphics));
-  void *ptr;
-  GtkWidget *widget;
+  struct graphics *g = NULL;
+  void *ptr = NULL;
+  GtkWidget *widget = NULL;
   GdkColor color;
 
-  ptr = NSA_GET_PTR (env, peer);
-  g->x_offset = g->y_offset = 0;
-
   gdk_threads_enter ();
 
+  g = (struct graphics *) g_malloc (sizeof (struct graphics));
+  ptr = NSA_GET_PTR (env, peer);
+  g->x_offset = 0;
+  g->y_offset = 0;
+
   widget = GTK_WIDGET (ptr);
   g->drawable = (GdkDrawable *) widget->window;
 
@@ -149,25 +154,25 @@
   gdk_gc_copy (g->gc, widget->style->fg_gc[GTK_STATE_NORMAL]);
   color = widget->style->fg[GTK_STATE_NORMAL];
 
-  gdk_threads_leave ();
-
   NSA_SET_PTR (env, obj, g);
+
+  gdk_threads_leave ();
 }
 
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GdkGraphics_connectSignals
   (JNIEnv *env, jobject obj, jobject peer)
 {
-  void *ptr;
-  jobject *gref;
+  void *ptr = NULL;
+  jobject *gref = NULL;
+
+  gdk_threads_enter ();
 
   NSA_SET_GLOBAL_REF (env, obj);
   gref = NSA_GET_GLOBAL_REF (env, obj);
 
   ptr = NSA_GET_PTR (env, peer);
 
-  gdk_threads_enter ();
-
   g_signal_connect_after (G_OBJECT (ptr), "realize",
                           G_CALLBACK (realize_cb), *gref);
 
@@ -178,14 +183,19 @@
 Java_gnu_java_awt_peer_gtk_GdkGraphics_dispose
   (JNIEnv *env, jobject obj)
 {
-  struct graphics *g;
+  struct graphics *g = NULL;
+
+  gdk_threads_enter ();
 
-  
   g = (struct graphics *) NSA_DEL_PTR (env, obj);
 
-  if (!g) return;		/* dispose has been called more than once */
-  
-  gdk_threads_enter ();
+  /* check if dispose has been called already */
+  if (!g)
+    {
+      gdk_threads_leave ();
+      return;
+    }
+
   XFlush (GDK_DISPLAY ());
 
   gdk_gc_destroy (g->gc);
@@ -197,22 +207,21 @@
 
   gdk_colormap_unref (g->cm);
 
-  gdk_threads_leave ();
-
+  g_free (g);
 
-  free (g);
+  gdk_threads_leave ();
 }
 
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GdkGraphics_translateNative
   (JNIEnv *env, jobject obj, jint x, jint y)
 {
-  struct graphics *g;
-
-  g = (struct graphics *) NSA_GET_PTR (env, obj);
+  struct graphics *g = NULL;
 
   gdk_threads_enter ();
 
+  g = (struct graphics *) NSA_GET_PTR (env, obj);
+
   g->x_offset += x;
   g->y_offset += y;
 
@@ -224,10 +233,12 @@
   (JNIEnv *env, jobject obj, jobject font, jstring str, jint x, jint y)
 {
   struct peerfont *pfont = NULL;
-  struct graphics *g;
-  const char *cstr;
-  int baseline_y;
-  PangoLayoutIter *iter;
+  struct graphics *g = NULL;
+  const char *cstr = NULL;
+  int baseline_y = 0;
+  PangoLayoutIter *iter = NULL;
+
+  gdk_threads_enter ();
 
   g = (struct graphics *) NSA_GET_PTR (env, obj);
   g_assert (g != NULL);
@@ -237,8 +248,6 @@
 
   cstr = (*env)->GetStringUTFChars (env, str, NULL);
 
-  gdk_threads_enter ();
-
   pango_layout_set_font_description (pfont->layout, pfont->desc);
   pango_layout_set_text (pfont->layout, cstr, -1);
   iter = pango_layout_get_iter (pfont->layout);
@@ -254,24 +263,27 @@
   pango_layout_set_text (pfont->layout, "", -1);
 
   gdk_flush ();
-  gdk_threads_leave ();
 
   (*env)->ReleaseStringUTFChars (env, str, cstr);
+
+  gdk_threads_leave ();
 }
 
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GdkGraphics_drawLine
   (JNIEnv *env, jobject obj, jint x, jint y, jint x2, jint y2)
 {
-  struct graphics *g;
+  struct graphics *g = NULL;
+
+  gdk_threads_enter ();
 
   g = (struct graphics *) NSA_GET_PTR (env, obj);
 
-  gdk_threads_enter ();
   gdk_draw_line (g->drawable, g->gc, 
 		 x + g->x_offset, y + g->y_offset, 
 		 x2 + g->x_offset, y2 + g->y_offset);
   gdk_flush ();
+
   gdk_threads_leave ();
 }
 
@@ -279,15 +291,16 @@
 Java_gnu_java_awt_peer_gtk_GdkGraphics_fillRect
   (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
 {
-  struct graphics *g;
-
-  g = (struct graphics *) NSA_GET_PTR (env, obj);
+  struct graphics *g = NULL;
 
   gdk_threads_enter ();
 
+  g = (struct graphics *) NSA_GET_PTR (env, obj);
+
   gdk_draw_rectangle (g->drawable, g->gc, TRUE, 
 		      x + g->x_offset, y + g->y_offset, width, height);
   gdk_flush ();
+
   gdk_threads_leave ();
 }
 
@@ -295,14 +308,16 @@
 Java_gnu_java_awt_peer_gtk_GdkGraphics_drawRect
   (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
 {
-  struct graphics *g;
+  struct graphics *g = NULL;
+
+  gdk_threads_enter ();
 
   g = (struct graphics *) NSA_GET_PTR (env, obj);
 
-  gdk_threads_enter ();
   gdk_draw_rectangle (g->drawable, g->gc, FALSE, 
 		      x + g->x_offset, y + g->y_offset, width, height);
   gdk_flush ();
+
   gdk_threads_leave ();
 }
 
@@ -311,11 +326,12 @@
   (JNIEnv *env, jobject obj, jint x, jint y, 
    jint width, jint height, jint dx, jint dy)
 {
-  struct graphics *g;
+  struct graphics *g = NULL;
+
+  gdk_threads_enter ();
 
   g = (struct graphics *) NSA_GET_PTR (env, obj);
 
-  gdk_threads_enter ();
   gdk_window_copy_area ((GdkWindow *)g->drawable,
 			g->gc,
 			x + g->x_offset + dx, y + g->y_offset + dy,
@@ -323,6 +339,7 @@
 			x + g->x_offset, y + g->y_offset,
 			width, height);
   gdk_flush ();
+
   gdk_threads_leave ();
 }
 
@@ -330,20 +347,21 @@
 Java_gnu_java_awt_peer_gtk_GdkGraphics_clearRect
   (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
 {
-  struct graphics *g;
+  struct graphics *g = NULL;
   GdkGCValues saved;
-  GtkWidget *widget;
+  GtkWidget *widget = NULL;
   union widget_union w;
 
-  g = (struct graphics *) NSA_GET_PTR (env, obj);
-
   gdk_threads_enter ();
 
+  g = (struct graphics *) NSA_GET_PTR (env, obj);
+
   if (!g)
     {
       gdk_threads_leave ();
       return;
     }
+
   if (GDK_IS_WINDOW (g->drawable))
     {
       w.widget = &widget;
@@ -363,6 +381,7 @@
     }
 
   gdk_flush ();
+
   gdk_threads_leave ();
 }
 
@@ -370,11 +389,14 @@
 Java_gnu_java_awt_peer_gtk_GdkGraphics_setFunction
   (JNIEnv *env, jobject obj, jint func)
 {
-  struct graphics *g;
-  g = (struct graphics *) NSA_GET_PTR (env, obj);
-  
+  struct graphics *g = NULL;
+
   gdk_threads_enter ();
+
+  g = (struct graphics *) NSA_GET_PTR (env, obj);
+
   gdk_gc_set_function (g->gc, func);
+
   gdk_threads_leave ();
 }
 
@@ -384,7 +406,9 @@
   (JNIEnv *env, jobject obj, jint red, jint green, jint blue)
 {
   GdkColor color;
-  struct graphics *g;
+  struct graphics *g = NULL;
+
+  gdk_threads_enter ();
 
   color.red = red << 8;
   color.green = green << 8;
@@ -392,7 +416,6 @@
 
   g = (struct graphics *) NSA_GET_PTR (env, obj);
   
-  gdk_threads_enter ();
   gdk_color_alloc (g->cm, &color);
   gdk_gc_set_foreground (g->gc, &color);
 
@@ -404,15 +427,17 @@
   (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height, 
    jint angle1, jint angle2)
 {
-  struct graphics *g;
+  struct graphics *g = NULL;
+
+  gdk_threads_enter ();
 
   g = (struct graphics *) NSA_GET_PTR (env, obj);
 
-  gdk_threads_enter ();
   gdk_draw_arc (g->drawable, g->gc, FALSE, 
 		x + g->x_offset, y + g->y_offset, 
 		width, height, angle1 << 6, angle2 << 6);
   gdk_flush ();
+
   gdk_threads_leave ();
 }  
 
@@ -448,19 +473,21 @@
   (JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints, 
    jint npoints)
 {
-  struct graphics *g;
-  GdkPoint *points;
+  struct graphics *g = NULL;
+  GdkPoint *points = NULL;
+
+  gdk_threads_enter ();
 
   g = (struct graphics *) NSA_GET_PTR (env, obj);
   points = translate_points (env, xpoints, ypoints, npoints,
 			     g->x_offset, g->y_offset);
 
-  gdk_threads_enter ();
   gdk_draw_lines (g->drawable, g->gc, points, npoints);
   gdk_flush ();
-  gdk_threads_leave ();
 
   g_free (points);
+
+  gdk_threads_leave ();
 }
 
 JNIEXPORT void JNICALL
@@ -468,8 +495,10 @@
   (JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints, 
    jint npoints)
 {
-  struct graphics *g;
-  GdkPoint *points;
+  struct graphics *g = NULL;
+  GdkPoint *points = NULL;
+
+  gdk_threads_enter ();
 
   g = (struct graphics *) NSA_GET_PTR (env, obj);
   points = translate_points (env, xpoints, ypoints, npoints,
@@ -480,12 +509,12 @@
   if (points[0].x != points[npoints-1].x || points[0].y != points[npoints-1].y)
     points[npoints++] = points[0];
 
-  gdk_threads_enter ();
   gdk_draw_lines (g->drawable, g->gc, points, npoints);
   gdk_flush ();
-  gdk_threads_leave ();
 
   g_free (points);
+
+  gdk_threads_leave ();
 }
 
 JNIEXPORT void JNICALL
@@ -493,18 +522,20 @@
   (JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints, 
    jint npoints)
 {
-  struct graphics *g;
-  GdkPoint *points;
+  struct graphics *g = NULL;
+  GdkPoint *points = NULL;
+
+  gdk_threads_enter ();
 
   g = (struct graphics *) NSA_GET_PTR (env, obj);
   points = translate_points (env, xpoints, ypoints, npoints,
 			     g->x_offset, g->y_offset);
-  gdk_threads_enter ();
   gdk_draw_polygon (g->drawable, g->gc, TRUE, points, npoints);
   gdk_flush ();
-  gdk_threads_leave ();
 
   g_free (points);
+
+  gdk_threads_leave ();
 }
 
 JNIEXPORT void JNICALL
@@ -512,15 +543,17 @@
   (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height, 
    jint angle1, jint angle2)
 {
-  struct graphics *g;
+  struct graphics *g = NULL;
+
+  gdk_threads_enter ();
 
   g = (struct graphics *) NSA_GET_PTR (env, obj);
 
-  gdk_threads_enter ();
   gdk_draw_arc (g->drawable, g->gc, TRUE, 
 		x + g->x_offset, y + g->y_offset, 
 		width, height, angle1 << 6, angle2 << 6);
   gdk_flush ();
+
   gdk_threads_leave ();
 }  
 
@@ -528,15 +561,17 @@
 Java_gnu_java_awt_peer_gtk_GdkGraphics_drawOval
   (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
 {
-  struct graphics *g;
+  struct graphics *g = NULL;
+
+  gdk_threads_enter ();
 
   g = (struct graphics *) NSA_GET_PTR (env, obj);
 
-  gdk_threads_enter ();
   gdk_draw_arc (g->drawable, g->gc, FALSE, 
 		x + g->x_offset, y + g->y_offset, 
 		width, height, 0, 23040);
   gdk_flush ();
+
   gdk_threads_leave ();
 }  
 
@@ -544,15 +579,17 @@
 Java_gnu_java_awt_peer_gtk_GdkGraphics_fillOval
   (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
 {
-  struct graphics *g;
+  struct graphics *g = NULL;
+
+  gdk_threads_enter ();
 
   g = (struct graphics *) NSA_GET_PTR (env, obj);
 
-  gdk_threads_enter ();
   gdk_draw_arc (g->drawable, g->gc, TRUE, 
 		x + g->x_offset, y + g->y_offset, 
 		width, height, 0, 23040);
   gdk_flush ();
+
   gdk_threads_leave ();
 }
 
@@ -560,9 +597,11 @@
 Java_gnu_java_awt_peer_gtk_GdkGraphics_setClipRectangle
   (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
 {
-  struct graphics *g;
+  struct graphics *g = NULL;
   GdkRectangle rectangle;
 
+  gdk_threads_enter ();
+
   g = (struct graphics *) NSA_GET_PTR (env, obj);
 
   rectangle.x = x + g->x_offset;
@@ -570,19 +609,19 @@
   rectangle.width = width;
   rectangle.height = height;
 
-  gdk_threads_enter ();
   gdk_gc_set_clip_rectangle (g->gc, &rectangle);
+
   gdk_threads_leave ();
 }
 
-static void realize_cb (GtkWidget *widget __attribute__ ((unused)), 
-			jobject peer)
+static void
+realize_cb (GtkWidget *widget __attribute__ ((unused)), jobject jgraphics)
 {
   gdk_threads_leave ();
 
-  (*gdk_env())->CallVoidMethod (gdk_env(), peer, initComponentGraphicsID);
+  (*gdk_env())->CallVoidMethod (gdk_env(), jgraphics, initComponentGraphicsID);
 
-  NSA_DEL_GLOBAL_REF (gdk_env(), peer);
+  NSA_DEL_GLOBAL_REF (gdk_env(), jgraphics);
 
   gdk_threads_enter ();
 }
Index: kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
diff -u kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c:1.15 kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c:1.16
--- kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c:1.15	Mon Jul  4 00:04:00 2005
+++ kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c	Mon Jul 25 16:03:22 2005
@@ -71,7 +71,9 @@
   (JNIEnv *env, jclass clazz)
 {
    gdk_threads_enter();
+
    NSA_G2D_INIT (env, clazz);
+
    gdk_threads_leave();
 }
 
@@ -366,7 +368,8 @@
   struct graphics2d *g = NULL, *g_old = NULL;
 
   gdk_threads_enter();
-  g = (struct graphics2d *) malloc (sizeof (struct graphics2d));
+
+  g = (struct graphics2d *) g_malloc (sizeof (struct graphics2d));
   g_assert (g != NULL);
   memset (g, 0, sizeof(struct graphics2d));
 
@@ -415,6 +418,7 @@
     cairo_pattern_set_filter (g->pattern, CAIRO_FILTER_FAST);
 
   NSA_SET_G2D_PTR (env, obj, g);
+
   gdk_threads_leave();
 }
 
@@ -423,11 +427,12 @@
 Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState___3III
 (JNIEnv *env, jobject obj, jintArray jarr, jint width, jint height)
 {
-  struct graphics2d *gr;
-  jint *cairobuf;
+  struct graphics2d *gr = NULL;
+  jint *cairobuf = NULL;
 
   gdk_threads_enter();
-  gr = (struct graphics2d *) malloc (sizeof (struct graphics2d));
+
+  gr = (struct graphics2d *) g_malloc (sizeof (struct graphics2d));
   g_assert (gr != NULL);
   memset (gr, 0, sizeof(struct graphics2d));
 
@@ -470,6 +475,7 @@
 			 width, height);
 
   NSA_SET_G2D_PTR (env, obj, gr);
+
   gdk_threads_leave();  
 }
 
@@ -477,10 +483,11 @@
 Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__II
   (JNIEnv *env, jobject obj, jint width, jint height)
 {
-  struct graphics2d *gr;
+  struct graphics2d *gr = NULL;
   
   gdk_threads_enter();
-  gr = (struct graphics2d *) malloc (sizeof (struct graphics2d));
+
+  gr = (struct graphics2d *) g_malloc (sizeof (struct graphics2d));
   g_assert (gr != NULL);
   memset (gr, 0, sizeof(struct graphics2d));
 
@@ -504,6 +511,7 @@
   if (gr->debug) printf ("constructed offscreen drawable of size (%d,%d)\n",
 			 width, height);
   NSA_SET_G2D_PTR (env, obj, gr);
+
   gdk_threads_leave();
 }
 
@@ -511,13 +519,25 @@
 Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable
   (JNIEnv *env, jobject self, jobject other, jint x, jint y)
 {
-  struct graphics2d *src = NULL, *dst = NULL;
-  gint s_height, s_width, d_height, d_width, height, width;
+  struct graphics2d *src = NULL;
+  struct graphics2d *dst = NULL;
+  gint s_height;
+  gint s_width;
+  gint d_height;
+  gint d_width;
+  gint height;
+  gint width;
   cairo_matrix_t matrix;
   cairo_operator_t tmp_op;
 
   gdk_threads_enter();
-  if (peer_is_disposed(env, self)) { gdk_threads_leave(); return; }
+  
+  if (peer_is_disposed(env, self))
+    {
+      gdk_threads_leave();
+      return;
+    }
+
   src = (struct graphics2d *)NSA_GET_G2D_PTR (env, other);
   dst = (struct graphics2d *)NSA_GET_G2D_PTR (env, self);
   g_assert (src != NULL);
@@ -553,6 +573,7 @@
   end_drawing_operation(env, dst);
 
   if (src->debug) printf ("copied %d x %d pixels from offscreen drawable\n", width, height);
+
   gdk_threads_leave();
 }
 
@@ -565,11 +586,17 @@
   void *ptr = NULL;
 
   gdk_threads_enter();
-  if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+  if (peer_is_disposed(env, obj))
+    {
+      gdk_threads_leave ();
+      return;
+    }
+
   ptr = NSA_GET_PTR (env, peer);
   g_assert (ptr != NULL);
 
-  gr = (struct graphics2d *) malloc (sizeof (struct graphics2d));
+  gr = (struct graphics2d *) g_malloc (sizeof (struct graphics2d));
   g_assert (gr != NULL);
   memset (gr, 0, sizeof(struct graphics2d));
 
@@ -590,6 +617,7 @@
     init_graphics2d_as_pixbuf (gr);
 
   NSA_SET_G2D_PTR (env, obj, gr);
+
   gdk_threads_leave();
 }
 
@@ -599,10 +627,10 @@
 {
   void *ptr;
 
-  ptr = NSA_GET_PTR (env, peer);
-
   gdk_threads_enter ();
 
+  ptr = NSA_GET_PTR (env, peer);
+
   g_signal_connect_after (G_OBJECT (ptr), "realize",
                           G_CALLBACK (realize_cb), obj);
 
@@ -616,7 +644,9 @@
   struct graphics2d *gr = NULL;
 
   gdk_threads_enter();
+
   gr = (struct graphics2d *) NSA_DEL_G2D_PTR (env, obj);
+
   if (gr == NULL) 
     {
       gdk_threads_leave();
@@ -641,7 +671,7 @@
     cairo_surface_destroy (gr->pattern_surface);
 
   if (gr->pattern_pixels)
-    free (gr->pattern_pixels);
+    g_free (gr->pattern_pixels);
 
   if (gr->mode == MODE_JAVA_ARRAY)
     {
@@ -652,11 +682,11 @@
 
   if (gr->debug) printf ("disposed of graphics2d\n");
 
-  free (gr);
+  g_free (gr);
+
   gdk_threads_leave();
 }
 
-
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradient 
   (JNIEnv *env, jobject obj, 
@@ -670,11 +700,18 @@
   cairo_surface_t *surf = NULL;
   cairo_t *cr2 = NULL;
   cairo_matrix_t mat;
+
+  gdk_threads_enter();
+
   gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
   g_assert (gr != NULL);
 
-  gdk_threads_enter();
-  if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+  if (peer_is_disposed(env, obj))
+    {
+      gdk_threads_leave ();
+      return;
+    }
+
   if (gr->debug) printf ("setGradient (%f,%f) -> (%f,%f); (%d,%d,%d,%d) -> (%d,%d,%d,%d)\n",
 			 x1, y1, 
 			 x2, y2, 
@@ -774,6 +811,7 @@
   gr->pattern = cairo_pattern_create_for_surface(surf);
 
   cairo_set_source (gr->cr, gr->pattern);
+
   gdk_threads_leave();
 }
 
@@ -785,7 +823,13 @@
   jint *jpixels = NULL;
 
   gdk_threads_enter();
-  if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; }
+
+  if (peer_is_disposed(env, obj))
+    {
+      gdk_threads_leave ();
+      return;
+    }

*** Patch too long, truncated ***



More information about the kaffe mailing list