From c1d32ecf828192ea864a5f9c0ebc223d52f11306 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 22 Aug 2002 23:54:29 +0000 Subject: [PATCH] Mark segment as destruction after letting X attach (makes it work on freebsd). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@14319 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++++ Source/art/ARTWindowBuffer.m | 17 +++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 619f2eb..cb11e08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-08-23 01:54 Alexander Malmberg + + * Source/art/ARTWindowBuffer.m (+artWindowBufferForWindow:): Mark + the segment for destruction after X has attached to it. + 2002-08-23 01:44 Alexander Malmberg * Source/art/ARTContext.m: Implement handling of non-rectangle diff --git a/Source/art/ARTWindowBuffer.m b/Source/art/ARTWindowBuffer.m index 43911a6..1063c0c 100644 --- a/Source/art/ARTWindowBuffer.m +++ b/Source/art/ARTWindowBuffer.m @@ -155,21 +155,22 @@ static int use_shape_hack = 0; /* this is an ugly hack :) */ if (!wi->shminfo.shmid == -1) NSLog(@"shmget() failed"); /* TODO */ -/* printf("shminfo.shmid=%08x %i bytes (%ix%i)\n", - wi->shminfo.shmid, wi->ximage->bytes_per_line * wi->ximage->height, - wi->ximage->width, wi->ximage->height);*/ wi->shminfo.shmaddr = wi->ximage->data = shmat(wi->shminfo.shmid, 0, 0); + wi->shminfo.readOnly = 1; + if (!XShmAttach(wi->display, &wi->shminfo)) + NSLog(@"XShmAttach() failed"); + + /* On some systems (eg. freebsd), X can't attach to the shared + segment if it's marked for destruction, so we make sure it's + attached before marking it. */ + XSync(wi->display,False); + /* Mark the segment as destroyed now. Since we're attached, it won't actually be destroyed, but if we crashed before doing this, it wouldn't be destroyed despite nobody being attached anymore. */ shmctl(wi->shminfo.shmid, IPC_RMID, 0); - -// printf("addr=%p\n", wi->shminfo.shmaddr); - wi->shminfo.readOnly = 1; - if (!XShmAttach(wi->display, &wi->shminfo)) - NSLog(@"XShmAttach() failed"); } else {