diff --git a/panda/src/cocoadisplay/cocoaGraphicsPipe.mm b/panda/src/cocoadisplay/cocoaGraphicsPipe.mm index 3734f37af8..5ab3d64341 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsPipe.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsPipe.mm @@ -177,7 +177,7 @@ load_display_information() { // Get processor information const NXArchInfo *ainfo = NXGetLocalArchInfo(); - _display_information->_cpu_brand_string = strdup(ainfo->description); + _display_information->_cpu_brand_string.assign(ainfo->description); // Get version of Mac OS X SInt32 major, minor, bugfix; diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index 27b8c2bf28..eb346a2b7d 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -63,6 +63,13 @@ #include #endif +#ifdef __APPLE__ +extern "C" { + void *objc_autoreleasePoolPush(); + void objc_autoreleasePoolPop(void *); +}; +#endif + using std::string; PT(GraphicsEngine) GraphicsEngine::_global_ptr; @@ -2586,6 +2593,11 @@ void GraphicsEngine::WindowRenderer:: do_frame(GraphicsEngine *engine, Thread *current_thread) { LightReMutexHolder holder(_wl_lock); +#ifdef __APPLE__ + // Enclose the entire frame in an autorelease pool. + void *pool = objc_autoreleasePoolPush(); +#endif + if (!_cull.empty()) { engine->cull_to_bins(_cull, current_thread); } @@ -2599,6 +2611,10 @@ do_frame(GraphicsEngine *engine, Thread *current_thread) { engine->process_events(_window, current_thread); } +#ifdef __APPLE__ + objc_autoreleasePoolPop(pool); +#endif + // If any GSG's on the list have no more outstanding pointers, clean them // up. (We are in the draw thread for all of these GSG's.) if (any_done_gsgs()) { @@ -2630,10 +2646,18 @@ void GraphicsEngine::WindowRenderer:: do_windows(GraphicsEngine *engine, Thread *current_thread) { LightReMutexHolder holder(_wl_lock); +#ifdef __APPLE__ + void *pool = objc_autoreleasePoolPush(); +#endif + engine->process_events(_window, current_thread); engine->make_contexts(_cdraw, current_thread); engine->make_contexts(_draw, current_thread); + +#ifdef __APPLE__ + objc_autoreleasePoolPop(pool); +#endif } /**