jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c
changeset 21939 5169fd314636
parent 20425 5964c0fc5cc0
child 22600 a509464f280f
--- a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c	Tue Dec 03 15:10:37 2013 -0800
+++ b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c	Wed Dec 04 12:29:18 2013 +0400
@@ -65,6 +65,7 @@
 static DisposeFunc X11SD_Dispose;
 static GetPixmapBgFunc X11SD_GetPixmapWithBg;
 static ReleasePixmapBgFunc X11SD_ReleasePixmapWithBg;
+extern int XShmAttachXErrHandler(Display *display, XErrorEvent *xerr);
 extern AwtGraphicsConfigDataPtr
     getGraphicsConfigFromComponentPeer(JNIEnv *env, jobject this);
 extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
@@ -532,8 +533,6 @@
 {
     XImage *img = NULL;
     XShmSegmentInfo *shminfo;
-    JNIEnv* env;
-    jboolean xShmAttachResult;
 
     shminfo = malloc(sizeof(XShmSegmentInfo));
     if (shminfo == NULL) {
@@ -573,8 +572,9 @@
 
     shminfo->readOnly = False;
 
-    env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-    xShmAttachResult = TryXShmAttach(env, awt_display, shminfo);
+    resetXShmAttachFailed();
+    EXEC_WITH_XERROR_HANDLER(XShmAttachXErrHandler,
+                             XShmAttach(awt_display, shminfo));
 
     /*
      * Once the XSync round trip has finished then we
@@ -583,7 +583,7 @@
      */
     shmctl(shminfo->shmid, IPC_RMID, 0);
 
-    if (xShmAttachResult == JNI_FALSE) {
+    if (isXShmAttachFailed() == JNI_TRUE) {
         J2dRlsTraceLn1(J2D_TRACE_ERROR,
                        "X11SD_SetupSharedSegment XShmAttach has failed: %s",
                        strerror(errno));