mirror of
				https://github.com/cookiengineer/audacity
				synced 2025-11-01 06:33:53 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			84 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			84 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| From 8c9c17ca704f6c2b1469c861497ac7676dd67347 Mon Sep 17 00:00:00 2001
 | |
| From: Paul Licameli <paul.licameli@audacityteam.org>
 | |
| Date: Sun, 31 Jul 2016 11:55:29 -0400
 | |
| Subject: [PATCH 1/3] Mac modal loops won't hang when other code uses old
 | |
|  Mutiprocessing...
 | |
| 
 | |
| ... if you call the new wxEventLoopBase::SetBusyWaiting(true).
 | |
| 
 | |
| But this has the undesirable consequence of high CPU usage while the loop idles,
 | |
| so this fix must be turned on only as needed by the application.
 | |
| 
 | |
| See the Audacity bug report that motivated this change:
 | |
| 
 | |
| http://bugzilla.audacityteam.org/show_bug.cgi?id=1338
 | |
| ---
 | |
|  include/wx/evtloop.h        | 10 ++++++++++
 | |
|  src/common/evtloopcmn.cpp   | 14 ++++++++++++++
 | |
|  src/osx/core/evtloop_cf.cpp |  3 ++-
 | |
|  3 files changed, 26 insertions(+), 1 deletion(-)
 | |
| 
 | |
| diff --git a/include/wx/evtloop.h b/include/wx/evtloop.h
 | |
| index 1133473..4b23610 100644
 | |
| --- include/wx/evtloop.h
 | |
| +++ include/wx/evtloop.h
 | |
| @@ -177,6 +177,16 @@ public:
 | |
|      // set currently active (running) event loop
 | |
|      static void SetActive(wxEventLoopBase* loop);
 | |
|  
 | |
| +#ifdef __WXMAC__
 | |
| +#define __WX_EVTLOOP_BUSY_WAITING__
 | |
| +    static bool GetBusyWaiting();
 | |
| +
 | |
| +    // If the argument is true, cause modal dialogs to busy-wait for events,
 | |
| +    // which seems to be necessary to avoid hanging when other code is using
 | |
| +    // the old Multiprocessing API
 | |
| +    static void SetBusyWaiting(bool busyWaiting);
 | |
| +#endif
 | |
| +
 | |
|  
 | |
|  protected:
 | |
|      // real implementation of Run()
 | |
| diff --git a/src/common/evtloopcmn.cpp b/src/common/evtloopcmn.cpp
 | |
| index f7b5138..325fd54 100644
 | |
| --- src/common/evtloopcmn.cpp
 | |
| +++ src/common/evtloopcmn.cpp
 | |
| @@ -56,6 +56,20 @@ void wxEventLoopBase::SetActive(wxEventLoopBase* loop)
 | |
|          wxTheApp->OnEventLoopEnter(loop);
 | |
|  }
 | |
|  
 | |
| +static bool g_busyWaiting = false;
 | |
| +
 | |
| +/* static */
 | |
| +bool wxEventLoopBase::GetBusyWaiting()
 | |
| +{
 | |
| +   return g_busyWaiting;
 | |
| +}
 | |
| +
 | |
| +/* static */
 | |
| +void wxEventLoopBase::SetBusyWaiting(bool busyWaiting)
 | |
| +{
 | |
| +   g_busyWaiting = busyWaiting;
 | |
| +}
 | |
| +
 | |
|  int wxEventLoopBase::Run()
 | |
|  {
 | |
|      // event loops are not recursive, you need to create another loop!
 | |
| diff --git a/src/osx/core/evtloop_cf.cpp b/src/osx/core/evtloop_cf.cpp
 | |
| index 7e70dec..510af80 100644
 | |
| --- src/osx/core/evtloop_cf.cpp
 | |
| +++ src/osx/core/evtloop_cf.cpp
 | |
| @@ -243,7 +243,8 @@ int wxCFEventLoop::DoProcessEvents()
 | |
|      }
 | |
|      else
 | |
|  #endif
 | |
| -        return DispatchTimeout( m_isInsideYield ? 0 : 1000 );
 | |
| +        return DispatchTimeout
 | |
| +            (m_isInsideYield || wxEventLoopBase::GetBusyWaiting() ? 0 : 1000 );
 | |
|  }
 | |
|  
 | |
|  bool wxCFEventLoop::Dispatch()
 | |
| -- 
 | |
| 2.3.2 (Apple Git-55)
 | |
| 
 |