From 2de87423688423cb96d445ca358cde3c3593ca9a Mon Sep 17 00:00:00 2001 From: Soren Jorvang Date: Sat, 29 Jan 2011 23:46:26 +0000 Subject: [PATCH] Equip any new threads with an NSAutoreleasePool. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6978 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/StdThread.h | 11 ++++++++++- Source/Core/Core/Src/Core.cpp | 19 ------------------- .../Core/Src/HW/WiimoteReal/WiimoteReal.cpp | 12 ------------ 3 files changed, 10 insertions(+), 32 deletions(-) diff --git a/Source/Core/Common/Src/StdThread.h b/Source/Core/Common/Src/StdThread.h index 859c66902c..41b856f831 100644 --- a/Source/Core/Common/Src/StdThread.h +++ b/Source/Core/Common/Src/StdThread.h @@ -18,6 +18,10 @@ #define USE_RVALUE_REFERENCES #endif +#ifdef __APPLE__ +#import +#endif + #if defined(_WIN32) // WIN32 @@ -256,9 +260,14 @@ private: template static THREAD_RETURN RunAndDelete(void* param) { +#ifdef __APPLE__ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; +#endif static_cast(param)->Run(); delete static_cast(param); - +#ifdef __APPLE__ + [pool release]; +#endif return 0; } }; diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 81ffe4ba99..a00097d755 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -20,10 +20,6 @@ #include #endif -#ifdef __APPLE__ -#import -#endif - #include "Setup.h" // Common #include "Atomic.h" #include "Thread.h" @@ -250,10 +246,6 @@ void Stop() // - Hammertime! void CpuThread() { -#ifdef __APPLE__ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; -#endif - CPluginManager &Plugins = CPluginManager::GetInstance(); const SCoreStartupParameter& _CoreParameter = SConfig::GetInstance().m_LocalCoreStartupParameter; @@ -292,9 +284,6 @@ void CpuThread() cpuRunloopQuit.Set(); -#ifdef __APPLE__ - [pool release]; -#endif return; } @@ -303,10 +292,6 @@ void CpuThread() // Call browser: Init():g_EmuThread(). See the BootManager.cpp file description for a complete call schedule. void EmuThread() { -#ifdef __APPLE__ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; -#endif - Host_UpdateMainFrame(); // Disable any menus or buttons at boot cpuRunloopQuit.Init(); @@ -492,10 +477,6 @@ void EmuThread() cpuRunloopQuit.Shutdown(); g_bStopping = false; - -#ifdef __APPLE__ - [pool release]; -#endif } // Set or get the running state diff --git a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp index bc47775849..e7debdfb39 100644 --- a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp +++ b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp @@ -28,10 +28,6 @@ #include "../WiimoteEmu/WiimoteHid.h" -#ifdef __APPLE__ -#import -#endif - unsigned int g_wiimote_sources[MAX_WIIMOTES]; namespace WiimoteReal @@ -308,10 +304,6 @@ void Wiimote::StartThread(Wiimote *wiimote) void Wiimote::ThreadFunc() { -#ifdef __APPLE__ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; -#endif - char thname[] = "Wiimote # Thread"; thname[8] = (char)('1' + index); Common::SetCurrentThreadName(thname); @@ -335,10 +327,6 @@ void Wiimote::ThreadFunc() } Host_ConnectWiimote(index, false); - -#ifdef __APPLE__ - [pool release]; -#endif } #ifndef _WIN32