[comp.windows.x] Another question, succinctly stated.

anderdla@CS.UOREGON.EDU (02/27/90)

This time my question is a little easier.  Simply stated, XMatchVisualInfo
and XGetVisualInfo both give me a segmentation fault when I call them.

I have tried allocating space for visualinfo and not allocating, makes
no difference.  Here's a short listing of applicable code:

	display=XOpenDisplay(NULL);
	if (display == NULL)
		quiterr("can`t open display; DISPLAY variable set?");
	screen = DefaultScreen(display);
	screenp = DefaultScreenOfDisplay(display);
	depth = DisplayPlanes(display,screen);
	gc= DefaultGC(display,screen);

	/* We need a visual class with changeable color maps. */

	stat=XMatchVisualInfo(display,screen,depth,PseudoColor,visinfo);
	if(stat==0){
		fprintf(stderr,"cannot get Pseudocolor class visual!\n");
		exit(0);
	}
	visual=visinfo->visual;
	
If there is not an appropriate visual it should just return 0 right?
Any ideas folks?
Note: Sun4 running X11/NeWS and OpenWindows.


--------------------------------------------------------------------

                   ______  ___                       
Darren Anderson     \     \  |    _       anderdla@cs.uoregon.edu
1656 Walnut St.      |     | |   / \                   
Eugene, Ore. 97403   |     | |  /___\      "MTV is like this very
                    /_____/  | /     \      big advertising agency,
                            /______   \     and its only client is 
                           /       \   \    itself."
                                                      
--------------------------------------------------------------------

rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (03/01/90)

    Simply stated, XMatchVisualInfo
    and XGetVisualInfo both give me a segmentation fault when I call them.

Your program fragment works fine for me (against R4) when wrapped with
appropriate declarations.  It also works when linked against the OpenWindows
Xlib (but pointed at an R4 server).  I also tried using a random number for the
class, and it "failed" correctly.  Are you sure you're passing a reasonable
value for visinfo?

    If there is not an appropriate visual it should just return 0 right?

Yes, but if you're on a color screen using OpenWindows it should still be
able to find PseudoColor.