[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Unexpected behaviour in pygame.image.load (patch)



Timothy Stranex wrote:
img = pygame.image.load(file('test.png'))
(don't forget the 'rb' argument flag for the windows users)

i've known there were some issues with this for awhile, the fact that you figured out what it was helped me find a better solution.

it turns out we really do want the RWop loader functions to close the RWop structure, because this is where the extra memory and objects get freed up. without the "close" argument set we will be leaking objects and memory.

when the "file-like" object is really just a file, there is a special case inside pygame that falls back to SDL_RWFromFP. and fortunately this function has a "close" argument of its own. if this close is set to 0 the objects will all be freed up when the RWop is done, but the actual file handle will not be closed. we have had it set to 1 in recent pygame releases (argh)

this is working very well now, i'm glad to see it is all finally resolved. big thanks for the investigation.