fix SDL leak by wrapping video_refresh() call with an NSAutoReleasePool

This commit is contained in:
asvitkine 2011-12-28 22:15:11 +00:00
parent cb0d1a818d
commit 45fbd1523f
2 changed files with 17 additions and 1 deletions

View File

@ -346,7 +346,13 @@ static void CustomApplicationMain (int argc, char **argv)
@end
// This is used from video_sdl.cpp.
void NSAutoReleasePool_wrap(void (*fn)(void))
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
fn();
[pool release];
}
#ifdef main
# undef main

View File

@ -66,6 +66,11 @@
#define DEBUG 0
#include "debug.h"
#if (defined(__APPLE__) && defined(__MACH__))
extern "C" {
void NSAutoReleasePool_wrap(void (*fn)(void));
}
#endif
// Supported video modes
using std::vector;
@ -2237,7 +2242,12 @@ static inline void do_video_refresh(void)
handle_events();
// Update display
#if (defined(__APPLE__) && defined(__MACH__))
// SDL expects an auto-release pool to be present.
NSAutoReleasePool_wrap(video_refresh);
#else
video_refresh();
#endif
#ifdef SHEEPSHAVER
// Set new cursor image if it was changed