[comp.windows.x] problem with XLoadQueryFont on HPUX machines?

tclark@honir.cs.cornell.edu (Timothy Clark) (09/11/90)

I've run into a problem with a very basic program which runs fine on a Sun
sparcstation running X11.4, but blows up on an HPUX 7.0 machine running X11.3.

All I'm doing is opening a display, creating and setting a tile, then when I
call XLoadQueryFont ... kaboom!  The error is:

>X Protocol error detected by server:  BadMatch, invalid parameter attributes
>  Failed request major op code 56 (X_ChangeGC)
>  Failed request minor op code 0 (if applicable)
>  ResourceID 0x0 in failed request (if applicable)
>  Serial number of failed request 7
>  Current serial number in output stream 8

The program code follows:

#include "spread.h"

/* debug (synchronous) X mode switch, non-zero = on */
#define _Xdebug 1 

static char gray_bits[] = {
        0x5555, 0xaaaa, 0x5555, 0xaaaa, 
        0x5555, 0xaaaa, 0x5555, 0xaaaa, 
        0x5555, 0xaaaa, 0x5555, 0xaaaa,
        0x5555, 0xaaaa, 0x5555, 0xaaaa};


void
main (argc, argv)
int   argc;
char  **argv;
{
    char displayname[32];
    char *fontname;
    XFontStruct   *font_info;    

    gethostname (name, 19);
    for (namelen = 0; name[namelen] && name[namelen] != '.' && namelen < 18; namelen++)
        continue;
    name[namelen] = '\0';

    dpy = XOpenDisplay (displayname);
    if (dpy == (Display *)0) {
        printf("Unable to establish xwindow connection.\n");
        exit(0);
    }

    screen = DefaultScreen(dpy);
    gc = DefaultGC(dpy, screen);
    black = BlackPixel(dpy, screen);
    white = WhitePixel(dpy, screen);

    tile = XCreateBitmapFromData(dpy, RootWindow(dpy, screen), 
                                 gray_bits, gray_width, gray_height);

    XSetTile(dpy, gc, tile); 

    fontname = NORMALFONT;   /* #define NORMALFONT "8x13" */

    font_info = XLoadQueryFont(dpy, fontname);
    printf("no problem ... past XLoadQueryFont\n");

}

As I said, it works fine on Sun, but blows up on HP risc machines.  I have 
tried everything I can think of ... any help would be greatly appreciated.

--Tim

tclark@cs.cornell.edu

klee@wsl.dec.com (Ken Lee) (09/11/90)

In article <45608@cornell.UUCP>, tclark@honir.cs.cornell.edu (Timothy Clark) writes:
|> All I'm doing is opening a display, creating and setting a tile, then when I
|> call XLoadQueryFont ... kaboom!  The error is:
|> 
|> >X Protocol error detected by server:  BadMatch, invalid parameter attributes
|> >  Failed request major op code 56 (X_ChangeGC)

An XSetTile request can cause this error if your GC and tile are of
different depths.  It is unlikely that the XLoadQueryFont has anything
to do with the error.

-- 
Ken Lee
DEC Western Software Laboratory, Palo Alto, Calif.
Internet: klee@wsl.dec.com
uucp: uunet!decwrl!klee

mouse@SHAMASH.MCRCIM.MCGILL.EDU (der Mouse) (09/12/90)

> I've run into a problem with a very basic program which runs fine on
> a Sun sparcstation running X11.4, but blows up on an HPUX 7.0 machine
> running X11.3.

> All I'm doing is opening a display, creating and setting a tile, then
> when I call XLoadQueryFont ... kaboom!  The error is:

> X Protocol error detected by server:  BadMatch, invalid parameter attributes
>   Failed request major op code 56 (X_ChangeGC)

> The program code follows:

> /* debug (synchronous) X mode switch, non-zero = on */
> #define _Xdebug 1 

This will not do what the comment implies you expect it to do.  _Xdebug
is not a #define but a variable.  You either want

int _Xdebug = 1;

or you want to call XSynchronize().  I am not sure the former works;
_Xdebug appears to me to be intended to be patched by debuggers, not
set by programs.  Calling XSynchronize should work fine.

>     gc = DefaultGC(dpy, screen);
>     tile = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
>                                  gray_bits, gray_width, gray_height);
>     XSetTile(dpy, gc, tile);

Wait a sec, who says the default GC is only one bit deep?  This
certainly makes a lot more sense as the source of the bogus ChangeGC
protocol request than the XLoadQueryFont below.

>     font_info = XLoadQueryFont(dpy, fontname);

> As I said, it works fine on Sun, but blows up on HP risc machines.  I
> have tried everything I can think of ... any help would be greatly
> appreciated.

Two things, then.  One, are all the Suns 1-bit and the HP more than 1
bit?  Two, did you ever try commenting out *just* the XLoadQueryFont
line and seeing if *that* ever worked on the HP?  If not, don't jump to
the conclusion that it's the line at fault....

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu