Skip to content

Commit 264a3a1

Browse files
author
eafton
committed
X11TK: Fix XDestroyImage fixme
1 parent 46fa43b commit 264a3a1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/video/x11/SDL_x11toolkit.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -782,16 +782,17 @@ static void X11Toolkit_DrawWindow(SDL_ToolkitWindowX11 *data) {
782782
SDL_Surface *pixmap_surface;
783783
SDL_Surface *put_surface;
784784

785-
/* FIXME: Implement SHM transport! */
785+
/* FIXME: Implement SHM transport? */
786786
pixmap_image = X11_XGetImage(data->display, data->drawable, 0, 0 , data->pixmap_width, data->pixmap_height, AllPlanes, ZPixmap);
787787
pixmap_surface = SDL_CreateSurfaceFrom(data->pixmap_width, data->pixmap_height, X11_GetPixelFormatFromVisualInfo(data->display, &data->vi), pixmap_image->data, pixmap_image->bytes_per_line);
788788
put_surface = SDL_ScaleSurface(pixmap_surface, data->window_width, data->window_height, SDL_SCALEMODE_LINEAR);
789789
put_image = X11_XCreateImage(data->display, data->visual, data->vi.depth, ZPixmap, 0, put_surface->pixels, data->window_width, data->window_height, 32, put_surface->pitch);
790790
X11_XPutImage(data->display, data->window, data->ctx, put_image, 0, 0, 0, 0, data->window_width, data->window_height);
791791

792-
/* FIXME: a leak is generated on each frame draw when using fractional scaling because these are commented out, they are commented out becaues they cause a double free! */
793-
/* X11_XDestroyImage(pixmap_image); */
794-
/* X11_XDestroyImage(put_image); */
792+
X11_XDestroyImage(pixmap_image);
793+
/* Needed because XDestroyImage results in a double-free otherwise */
794+
put_image->data = NULL;
795+
X11_XDestroyImage(put_image);
795796
SDL_DestroySurface(pixmap_surface);
796797
SDL_DestroySurface(put_surface);
797798
}

0 commit comments

Comments
 (0)