]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxEventLoop::GetActive()
authorVáclav Slavík <vslavik@fastmail.fm>
Sun, 12 Aug 2001 22:10:20 +0000 (22:10 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Sun, 12 Aug 2001 22:10:20 +0000 (22:10 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11361 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/evtloop.h
src/gtk/evtloop.cpp
src/gtk1/evtloop.cpp
src/msw/evtloop.cpp

index 4e90d3d80326a5c662a4c1305517fc039d8feb88..2a71defd7a741c8144070a3012d04452708aa5f5 100644 (file)
@@ -43,10 +43,15 @@ public:
 
     // is the event loop running now?
     virtual bool IsRunning() const;
+    
+    // return currently active (running) event loop, may be NULL
+    static wxEventLoop *GetActive() { return ms_activeLoop; }
 
 protected:
     // the pointer to the port specific implementation class
     class WXDLLEXPORT wxEventLoopImpl *m_impl;
+    // the pointer to currently active loop
+    static wxEventLoop *ms_activeLoop;
 };
 
 #endif // _WX_EVTLOOP_H_
index 268cfba85b9607fe280a21666ce4f5002d568c8f..361fa3ab92738735593d27e6d0a621cd70cd5c8c 100644 (file)
@@ -62,6 +62,8 @@ private:
 // wxEventLoop running and exiting
 // ----------------------------------------------------------------------------
 
+wxEventLoop *wxEventLoop::ms_activeLoop = NULL;
+
 wxEventLoop::~wxEventLoop()
 {
     wxASSERT_MSG( !m_impl, _T("should have been deleted in Run()") );
@@ -77,6 +79,9 @@ int wxEventLoop::Run()
     // event loops are not recursive, you need to create another loop!
     wxCHECK_MSG( !IsRunning(), -1, _T("can't reenter a message loop") );
 
+    wxEventLoop *oldLoop = ms_activeLoop;
+    ms_activeLoop = this;
+
     m_impl = new wxEventLoopImpl;
 
     gtk_main();
@@ -85,6 +90,8 @@ int wxEventLoop::Run()
     delete m_impl;
     m_impl = NULL;
 
+    ms_activeLoop = oldLoop;
+
     return exitcode;
 }
 
index 268cfba85b9607fe280a21666ce4f5002d568c8f..361fa3ab92738735593d27e6d0a621cd70cd5c8c 100644 (file)
@@ -62,6 +62,8 @@ private:
 // wxEventLoop running and exiting
 // ----------------------------------------------------------------------------
 
+wxEventLoop *wxEventLoop::ms_activeLoop = NULL;
+
 wxEventLoop::~wxEventLoop()
 {
     wxASSERT_MSG( !m_impl, _T("should have been deleted in Run()") );
@@ -77,6 +79,9 @@ int wxEventLoop::Run()
     // event loops are not recursive, you need to create another loop!
     wxCHECK_MSG( !IsRunning(), -1, _T("can't reenter a message loop") );
 
+    wxEventLoop *oldLoop = ms_activeLoop;
+    ms_activeLoop = this;
+
     m_impl = new wxEventLoopImpl;
 
     gtk_main();
@@ -85,6 +90,8 @@ int wxEventLoop::Run()
     delete m_impl;
     m_impl = NULL;
 
+    ms_activeLoop = oldLoop;
+
     return exitcode;
 }
 
index 8c9f562a332c712ed73892767404cc0ae5882577..dca66aba583c6d2cdbbd0789ae69f67dfef167c8 100644 (file)
@@ -146,6 +146,8 @@ bool wxEventLoopImpl::SendIdleMessage()
 // wxEventLoop implementation
 // ============================================================================
 
+wxEventLoop *wxEventLoop::ms_activeLoop = NULL;
+
 // ----------------------------------------------------------------------------
 // wxEventLoop running and exiting
 // ----------------------------------------------------------------------------
@@ -166,6 +168,9 @@ int wxEventLoop::Run()
     wxCHECK_MSG( !IsRunning(), -1, _T("can't reenter a message loop") );
 
     m_impl = new wxEventLoopImpl;
+    
+    wxEventLoop *oldLoop = ms_activeLoop;
+    ms_activeLoop = this;
 
     for ( ;; )
     {
@@ -191,6 +196,8 @@ int wxEventLoop::Run()
     delete m_impl;
     m_impl = NULL;
 
+    ms_activeLoop = oldLoop;
+
     return exitcode;
 }