share wxEventLoop::IsRunning() implementation between all ports; moved wxEventLoopActivator used by it in wx/evtloop.h instead of duplicating it in 3 different .cpp files (and not using it at all in 3 other ones)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36842 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-01-12 16:56:48 +00:00
parent f29d3d6133
commit 77fb1a02aa
11 changed files with 44 additions and 116 deletions

View File

@@ -48,34 +48,6 @@
WX_DEFINE_LIST(wxMsgList)
#endif // wxUSE_THREADS
// ----------------------------------------------------------------------------
// helper class
// ----------------------------------------------------------------------------
// this object sets the wxEventLoop given to the ctor as the currently active
// one and unsets it in its dtor
class wxEventLoopActivator
{
public:
wxEventLoopActivator(wxEventLoop **pActive,
wxEventLoop *evtLoop)
{
m_pActive = pActive;
m_evtLoopOld = *pActive;
*pActive = evtLoop;
}
~wxEventLoopActivator()
{
// restore the previously active event loop
*m_pActive = m_evtLoopOld;
}
private:
wxEventLoop *m_evtLoopOld;
wxEventLoop **m_pActive;
};
// ============================================================================
// wxEventLoop implementation
// ============================================================================
@@ -223,11 +195,6 @@ bool wxEventLoop::PreProcessMessage(WXMSG *msg)
// wxEventLoop running and exiting
// ----------------------------------------------------------------------------
bool wxEventLoop::IsRunning() const
{
return ms_activeLoop == this;
}
int wxEventLoop::Run()
{
// event loops are not recursive, you need to create another loop!
@@ -236,7 +203,7 @@ int wxEventLoop::Run()
// ProcessIdle() and Dispatch() below may throw so the code here should
// be exception-safe, hence we must use local objects for all actions we
// should undo
wxEventLoopActivator activate(&ms_activeLoop, this);
wxEventLoopActivator activate(this);
// we must ensure that OnExit() is called even if an exception is thrown
// from inside Dispatch() but we must call it from Exit() in normal