[GRASS-SVN] r30861 - grass/trunk/visualization/nviz/src

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Apr 4 19:27:43 EDT 2008


Author: glynn
Date: 2008-04-04 19:27:43 -0400 (Fri, 04 Apr 2008)
New Revision: 30861

Modified:
   grass/trunk/visualization/nviz/src/do_zoom.c
Log:
Install Tk error handler to prevent GLX failures from killing NVIZ.


Modified: grass/trunk/visualization/nviz/src/do_zoom.c
===================================================================
--- grass/trunk/visualization/nviz/src/do_zoom.c	2008-04-04 14:56:26 UTC (rev 30860)
+++ grass/trunk/visualization/nviz/src/do_zoom.c	2008-04-04 23:27:43 UTC (rev 30861)
@@ -22,6 +22,7 @@
 #ifdef OPENGL_X11
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
+#include <X11/Xmu/Xmu.h>
 #include <GL/glx.h>
 
 static Display *dpy;
@@ -350,9 +351,18 @@
 #endif
 }
 
+static int Error_Handler(ClientData closure, XErrorEvent *event)
+{
+    if (!dpy)
+	return 0;
+    XmuPrintDefaultErrorMessage(dpy, event, stderr);
+    return 0;
+}
+
 int Create_OS_Ctx(int width, int height)
 {
 #if defined(OPENGL_X11) && (defined(HAVE_PBUFFERS) || defined(HAVE_PIXMAPS))
+    static int initialized;
     dpy = togl_display();
     if (dpy == NULL) {
 	fprintf(stderr, "Togl_Display Failed!\n");
@@ -360,6 +370,14 @@
     }
     scr = togl_screen_number();
 
+    if (!initialized)
+    {
+	int major, event, error;
+	if (XQueryExtension(dpy, "GLX", &major, &event, &error))
+	    Tk_CreateErrorHandler(dpy, -1, major, -1, Error_Handler, NULL);
+	initialized = 1;
+    }
+
     create_pbuffer(width, height);
 #ifdef HAVE_PBUFFERS
     if (!pbuffer)



More information about the grass-commit mailing list