handle shm addr return right

SVN revision: 17325
This commit is contained in:
Carsten Haitzler 2005-10-08 14:59:45 +00:00
parent b351ead33a
commit 97f6242fca
2 changed files with 7 additions and 2 deletions

View File

@ -77,7 +77,7 @@ _xr_image_info_get(Display *disp, Drawable draw, Visual *vis)
if (shm_info.shmid >= 0)
{
shm_info.shmaddr = xim->data = shmat(shm_info.shmid, 0, 0);
if (shm_info.shmaddr != NULL)
if ((shm_info.shmaddr != NULL) && (shm_info.shmaddr != -1))
{
XErrorHandler ph;
@ -166,7 +166,7 @@ _xr_image_new(Ximage_Info *xinf, int w, int h, int depth)
if (xim->shm_info->shmid >= 0)
{
xim->shm_info->shmaddr = xim->xim->data = shmat(xim->shm_info->shmid, 0, 0);
if (xim->shm_info->shmaddr != NULL)
if ((xim->shm_info->shmaddr != NULL) && (xim->shm_info->shmaddr != -1))
{
XErrorHandler ph;

View File

@ -21,6 +21,7 @@ _xr_render_surface_new(Ximage_Info *xinf, int w, int h, XRenderPictFormat *fmt,
rs->depth = fmt->depth;
rs->allocated = 1;
rs->draw = XCreatePixmap(xinf->disp, xinf->root, w, h, fmt->depth);
rs->xinf->references++;
att.dither = 0;
att.component_alpha = 0;
att.repeat = 0;
@ -46,6 +47,7 @@ _xr_render_surface_adopt(Ximage_Info *xinf, Drawable draw, int w, int h, int alp
if (fmt->depth == 32) rs->alpha = 1;
rs->allocated = 0;
rs->draw = draw;
rs->xinf->references++;
att.dither = 0;
att.component_alpha = 0;
att.repeat = 0;
@ -67,6 +69,7 @@ _xr_render_surface_format_adopt(Ximage_Info *xinf, Drawable draw, int w, int h,
rs->alpha = alpha;
rs->depth = fmt->depth;
if (fmt->depth == 32) rs->alpha = 1;
rs->xinf->references++;
rs->allocated = 0;
rs->draw = draw;
att.dither = 0;
@ -81,6 +84,8 @@ _xr_render_surface_free(Xrender_Surface *rs)
{
if (rs->allocated) XFreePixmap(rs->xinf->disp, rs->draw);
XRenderFreePicture(rs->xinf->disp, rs->pic);
_xr_image_info_free(rs->xinf);
rs->xinf = NULL;
free(rs);
}