# HG changeset patch # User Sam Lantinga # Date 1229173853 0 # Node ID 3b595278f8130e4a8255649a16a0066b820326df # Parent eec7adc3d1c53ec1a1f400dc95b0154e96e8ac9c Fixed BadMatch error in X11 renderer diff -r eec7adc3d1c5 -r 3b595278f813 src/video/x11/SDL_x11render.c --- a/src/video/x11/SDL_x11render.c Sat Dec 13 12:34:28 2008 +0000 +++ b/src/video/x11/SDL_x11render.c Sat Dec 13 13:10:53 2008 +0000 @@ -427,6 +427,15 @@ &attributes); depth = X11_GetDepthFromPixelFormat(data->format); + /* The image/pixmap depth must be the same as the window or you + get a BadMatch error when trying to putimage or copyarea. + */ + if (depth != attributes.depth) { + X11_DestroyTexture(renderer, texture); + SDL_SetError("Texture format doesn't match window format"); + return -1; + } + if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING) { #ifndef NO_SHARED_MEMORY XShmSegmentInfo *shminfo = &data->shminfo; @@ -475,6 +484,7 @@ { data->pixels = SDL_malloc(texture->h * data->pitch); if (!data->pixels) { + X11_DestroyTexture(renderer, texture); SDL_OutOfMemory(); return -1; } @@ -485,6 +495,7 @@ SDL_BYTESPERPIXEL(data->format) * 8, data->pitch); if (!data->image) { + X11_DestroyTexture(renderer, texture); SDL_SetError("XCreateImage() failed"); return -1; } @@ -494,6 +505,7 @@ XCreatePixmap(renderdata->display, renderdata->window, texture->w, texture->h, depth); if (data->pixmap == None) { + X11_DestroyTexture(renderer, texture); SDL_SetError("XCteatePixmap() failed"); return -1; } @@ -503,6 +515,7 @@ ZPixmap, 0, NULL, texture->w, texture->h, SDL_BYTESPERPIXEL(data->format) * 8, data->pitch); if (!data->image) { + X11_DestroyTexture(renderer, texture); SDL_SetError("XCreateImage() failed"); return -1; }