// 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_
// wxEventLoop running and exiting
// ----------------------------------------------------------------------------
+wxEventLoop *wxEventLoop::ms_activeLoop = NULL;
+
wxEventLoop::~wxEventLoop()
{
wxASSERT_MSG( !m_impl, _T("should have been deleted in 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();
delete m_impl;
m_impl = NULL;
+ ms_activeLoop = oldLoop;
+
return exitcode;
}
// wxEventLoop running and exiting
// ----------------------------------------------------------------------------
+wxEventLoop *wxEventLoop::ms_activeLoop = NULL;
+
wxEventLoop::~wxEventLoop()
{
wxASSERT_MSG( !m_impl, _T("should have been deleted in 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();
delete m_impl;
m_impl = NULL;
+ ms_activeLoop = oldLoop;
+
return exitcode;
}
// wxEventLoop implementation
// ============================================================================
+wxEventLoop *wxEventLoop::ms_activeLoop = NULL;
+
// ----------------------------------------------------------------------------
// wxEventLoop running and exiting
// ----------------------------------------------------------------------------
wxCHECK_MSG( !IsRunning(), -1, _T("can't reenter a message loop") );
m_impl = new wxEventLoopImpl;
+
+ wxEventLoop *oldLoop = ms_activeLoop;
+ ms_activeLoop = this;
for ( ;; )
{
delete m_impl;
m_impl = NULL;
+ ms_activeLoop = oldLoop;
+
return exitcode;
}