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:
@@ -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
|
||||
|
Reference in New Issue
Block a user