Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!ncar!boulder!stan!garya!garya From: garya@garya.Solbourne.COM (Gary Aitken) Newsgroups: comp.windows.x Subject: XAllocColor bug Message-ID: <1990Nov30.204721.21570@Solbourne.COM> Date: 30 Nov 90 20:47:21 GMT Sender: news@Solbourne.COM Organization: Solbourne Computer, Inc. Lines: 55 The following program demonstrates a bug when trying to allocate a color cell. This is in the X11R4 server. ===================== cut here ====================== /* * If: * A color cell is allocated using XAllocColorCells * The allocated color cell is configured using XStoreColor * Then: * An attempt to use the same color cell via XAllocColor will fail in one of two ways: * If additional color cell is available: (The case in the program below) * A new one will be allocated. * Else: * XAllocColor will fail (return 0) * Both of these are bugs; in both cases, the previously allocated cell should be returned */ #include #include main (argc, argv) int argc ; char **argv ; { Display *dpy ; int screen; Window win ; XColor clr_def ; Colormap color_map ; Colormap def_color_map ; unsigned long pxl ; dpy = XOpenDisplay(0); screen = DefaultScreen(dpy); def_color_map = DefaultColormapOfScreen(ScreenOfDisplay(dpy,screen)) ; XSynchronize(dpy,1) ; win = XDefaultRootWindow(dpy) ; if (color_map = XCreateColormap(dpy, win, DefaultVisual(dpy,screen), AllocNone)) { XAllocColorCells(dpy, color_map, True, 0, 0, &pxl, 1); printf("pixel allocated: %d\n",pxl) ; clr_def.pixel = pxl ; clr_def.red = 0 ; clr_def.green = 0 ; clr_def.blue = 0 ; clr_def.flags = DoRed|DoGreen|DoBlue ; XStoreColor(dpy, color_map, clr_def); if (XAllocColor(dpy,color_map,&clr_def)) printf("pixel: %d\n",clr_def.pixel) ; } } -- Gary Aitken Solbourne Computer Inc. ARPA: garya@Solbourne.COM Longmont, CO UUCP: !{boulder,sun}!stan!garya