]> git.saurik.com Git - wxWidgets.git/commitdiff
OSX adaptions
authorStefan Csomor <csomor@advancedconcepts.ch>
Sat, 27 Jul 2013 19:00:25 +0000 (19:00 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Sat, 27 Jul 2013 19:00:25 +0000 (19:00 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74603 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/evtloop.h
include/wx/osx/cocoa/evtloop.h
src/osx/cocoa/evtloop.mm

index 8dd5d6eb7b6f201f60cd49ddf5d55c615c69bee5..d83f5d23f6cd7aadf66cdaedc0b8407cf29c3c9a 100644 (file)
@@ -203,9 +203,9 @@ protected:
     bool m_isInsideYield;
     long m_eventsToProcessInsideYield;
 
-private:
     // this flag is set on entry into Run() and reset before leaving it
     bool m_isInsideRun;
+private:
 
     wxDECLARE_NO_COPY_CLASS(wxEventLoopBase);
 };
index ab15dd94af898ac91c5a6aa9239db857e6752b09..7ae6981b29250eccf9897dffde0ee51ff1e76f89 100644 (file)
@@ -16,6 +16,8 @@ public:
     wxGUIEventLoop();
     ~wxGUIEventLoop();
     
+    int Run();
+    
     void BeginModalSession( wxWindow* modalWindow );
     
     void EndModalSession();
@@ -25,6 +27,8 @@ public:
     void OSXUseLowLevelWakeup(bool useIt)
         { m_osxLowLevelWakeUp = useIt ; }
     
+    void OSXOnWillTerminate();
+    
 protected:
     virtual int DoDispatchTimeout(unsigned long timeout);
 
index 2a27139d35c1052661a0376bdcf8bdfc0dc08ef1..089695d1d817b0974c261319a8bc4b0b853ff529 100644 (file)
@@ -242,6 +242,26 @@ int wxGUIEventLoop::DoDispatchTimeout(unsigned long timeout)
 
 static int gs_loopNestingLevel = 0;
 
+int wxGUIEventLoop::Run()
+{
+    // because we are using native callbacks for notifying about entering and exiting
+    // the main event loop, we must this leave out here
+    
+    // event loops are not recursive, you need to create another loop!
+    wxCHECK_MSG( !IsInsideRun(), -1, wxT("can't reenter a message loop") );
+    
+    // We might be called again, after a previous call to ScheduleExit(), so
+    // reset this flag.
+    m_shouldExit = false;
+    
+    // Set this variable to true for the duration of this method.
+    m_isInsideRun = true;
+    wxON_BLOCK_EXIT_SET(m_isInsideRun, false);
+    
+    // Finally really run the loop.
+    return DoRun();
+}
+
 void wxGUIEventLoop::OSXDoRun()
 {
     /*
@@ -340,7 +360,8 @@ void wxGUIEventLoop::OSXDoStop()
     // We should only stop the top level event loop.
     if ( gs_loopNestingLevel <= 1 )
     {
-        [NSApp stop:0];
+        // using terminate support all native notifications
+        [NSApp terminate:0];
     }
 
     // For the top level loop only calling stop: is not enough when called from
@@ -350,6 +371,11 @@ void wxGUIEventLoop::OSXDoStop()
     WakeUp();
 }
 
+void wxGUIEventLoop::OSXOnWillTerminate()
+{
+    OnExit();
+}
+
 void wxGUIEventLoop::WakeUp()
 {
     // NSEvent* cevent = [NSApp currentEvent];