On Thu, 4 Dec 2003, Callum Prentice wrote: > i have a methods in a class to create a shared memory x image - it creates and stores an > xImage in the usual way: > > XShmSegmentInfo shminfo; > ximage = XShmCreateImage(..., &shminfo); > shminfo.shmid = shmget (.., ximage->height * ximage->bytes_per_line, ...); > shminfo.shmaddr = ximage->data = shmat(shminfo.shmid, 0, 0); > shminfo.readOnly = False; > XShmAttach (display, &shminfo); > > i call this method in several places and only call XShmPutImage on the xImage later in my > code. > > i get an X error: > > "X Error of failed request: BadValue (integer parameter out of range for operation) > Major opcode of failed request: 144 (MIT-SHM) > Minor opcode of failed request: 3 (X_ShmPutImage)" > > which appears to be because the shared segment info has changed. I think you've misinterpreted this. Aside from corruption of the ximage data structure, the only time BadValue is returned is if your source rectangle passed to XShmPutImage lies outside of the XImage (or if you pass junk for the send_event). Check your dimensions passed to XShmPutImage. > > if i save the shminfo each time and then re-attach it to the display before i call > XShmPutImage, i still get the problem. > > any ideas ? what is the right thing to do here. > > also - in the code i'm using there is a call to: > > shmctl ( shmInfo.shmid, IPC_RMID, NULL ); > > just after it's created - surely this is wrong and i shouldn't remeove the sgm segment until > my program is finishing. Segments don't disappear until after they are removed and the last process attaching to them has detached. Even if you remove it, it will not go away until after you detach. When your program quits or crashes, it detaches automatically. However, it does not get removed automatically, so if the app quits or crashes before removing the segment, the segment will get leaked. That's why it's common practice to attach and then remove a segment. Mark. _______________________________________________ XFree86 mailing list XFree86@xxxxxxxxxxx http://XFree86.Org/mailman/listinfo/xfree86