src/solaris/native/sun/awt/awt_GraphicsEnv.c

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -903,18 +903,23 @@
 #ifdef MITSHM
 
 static jint canUseShmExt = UNSET_MITSHM;
 static jint canUseShmExtPixmaps = UNSET_MITSHM;
 static jboolean xshmAttachFailed = JNI_FALSE;
+static int j2dxErrHandlerCallsCount = 0;
 
 int J2DXErrHandler(Display *display, XErrorEvent *xerr) {
     int ret = 0;
     if (xerr->minor_code == X_ShmAttach) {
         xshmAttachFailed = JNI_TRUE;
     } else {
+        // Verify that this handler is not called twice for the same error.
+        if (++j2dxErrHandlerCallsCount < 2) {
         ret = (*xerror_saved_handler)(display, xerr);
     }
+        j2dxErrHandlerCallsCount--;
+    }
     return ret;
 }
 jboolean isXShmAttachFailed() {
     return xshmAttachFailed;
 }