8134028: [PIT] XToolkit, strange behavior of robot.createScreenCapture(): looks like a native crash in X11/GTK
authorazvegint
Fri, 21 Aug 2015 10:43:47 -0700
changeset 32297 1f709146c4cb
parent 32296 ee186af6c3ca
child 32298 453620b46da1
8134028: [PIT] XToolkit, strange behavior of robot.createScreenCapture(): looks like a native crash in X11/GTK Reviewed-by: alexsch, serb
jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c	Mon Aug 17 10:12:16 2015 -0700
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c	Fri Aug 21 10:43:47 2015 -0700
@@ -259,6 +259,7 @@
 
     if (isGtkSupported) {
         GdkPixbuf *pixbuf;
+        (*fp_gdk_threads_enter)();
         GdkWindow *root = (*fp_gdk_get_default_root_window)();
 
         pixbuf = (*fp_gdk_pixbuf_get_from_drawable)(NULL, root, NULL,
@@ -279,6 +280,7 @@
                 ary = (*env)->GetPrimitiveArrayCritical(env, pixelArray, NULL);
                 if (!ary) {
                     (*fp_g_object_unref)(pixbuf);
+                    (*fp_gdk_threads_leave)();
                     AWT_UNLOCK();
                     return;
                 }
@@ -298,6 +300,7 @@
                 (*env)->ReleasePrimitiveArrayCritical(env, pixelArray, ary, 0);
                 if ((*env)->ExceptionCheck(env)) {
                     (*fp_g_object_unref)(pixbuf);
+                    (*fp_gdk_threads_leave)();
                     AWT_UNLOCK();
                     return;
                 }
@@ -305,6 +308,7 @@
             }
             (*fp_g_object_unref)(pixbuf);
         }
+        (*fp_gdk_threads_leave)();
     }
 
     if (gtk_failed) {