src/video/x11/SDL_x11image.c
changeset 810 26a0e2d69d39
parent 769 b8d311d90021
child 1168 045f186426e1
equal deleted inserted replaced
809:dba98fb391e7 810:26a0e2d69d39
    42 static int shm_error;
    42 static int shm_error;
    43 static int (*X_handler)(Display *, XErrorEvent *) = NULL;
    43 static int (*X_handler)(Display *, XErrorEvent *) = NULL;
    44 static int shm_errhandler(Display *d, XErrorEvent *e)
    44 static int shm_errhandler(Display *d, XErrorEvent *e)
    45 {
    45 {
    46         if ( e->error_code == BadAccess ) {
    46         if ( e->error_code == BadAccess ) {
    47         	shm_error = 1;
    47         	shm_error = True;
    48         	return(0);
    48         	return(0);
    49         } else
    49         } else
    50 		return(X_handler(d,e));
    50 		return(X_handler(d,e));
    51 }
    51 }
    52 
    52 
    63 			shm_error = False;
    63 			shm_error = False;
    64 			X_handler = XSetErrorHandler(shm_errhandler);
    64 			X_handler = XSetErrorHandler(shm_errhandler);
    65 			XShmAttach(SDL_Display, &shminfo);
    65 			XShmAttach(SDL_Display, &shminfo);
    66 			XSync(SDL_Display, True);
    66 			XSync(SDL_Display, True);
    67 			XSetErrorHandler(X_handler);
    67 			XSetErrorHandler(X_handler);
    68 			if (shm_error)
    68 			if ( shm_error )
    69 				shmdt(shminfo.shmaddr);
    69 				shmdt(shminfo.shmaddr);
    70 		} else {
    70 		} else {
    71 			shm_error = True;
    71 			shm_error = True;
    72 		}
    72 		}
    73 		shmctl(shminfo.shmid, IPC_RMID, NULL);
    73 		shmctl(shminfo.shmid, IPC_RMID, NULL);