diff --git a/include/wx/evtloop.h b/include/wx/evtloop.h index 42b00f2d03..d77cbf13de 100644 --- a/include/wx/evtloop.h +++ b/include/wx/evtloop.h @@ -88,7 +88,7 @@ public: virtual void Exit(int rc = 0); virtual bool Pending() const; virtual bool Dispatch(); - virtual bool IsRunning() const { return m_impl != NULL; } + virtual bool IsRunning() const { return GetActive() == this; } protected: // the pointer to the port specific implementation class diff --git a/src/gtk/evtloop.cpp b/src/gtk/evtloop.cpp index acca1472fe..74d4132b43 100644 --- a/src/gtk/evtloop.cpp +++ b/src/gtk/evtloop.cpp @@ -31,6 +31,7 @@ #ifndef WX_PRECOMP #endif //WX_PRECOMP +#include "wx/app.h" #include "wx/evtloop.h" #include @@ -103,9 +104,20 @@ void wxEventLoop::Exit(int rc) // wxEventLoop message processing dispatching // ---------------------------------------------------------------------------- +extern bool g_isIdle; + bool wxEventLoop::Pending() const { - return gtk_events_pending() > 0; + if (wxTheApp && !g_isIdle) + { + // We need to remove idle callbacks or gtk_events_pending will + // never return false. + gtk_idle_remove( wxTheApp->m_idleTag ); + wxTheApp->m_idleTag = 0; + g_isIdle = TRUE; + } + + return gtk_events_pending(); } bool wxEventLoop::Dispatch() diff --git a/src/gtk1/evtloop.cpp b/src/gtk1/evtloop.cpp index acca1472fe..74d4132b43 100644 --- a/src/gtk1/evtloop.cpp +++ b/src/gtk1/evtloop.cpp @@ -31,6 +31,7 @@ #ifndef WX_PRECOMP #endif //WX_PRECOMP +#include "wx/app.h" #include "wx/evtloop.h" #include @@ -103,9 +104,20 @@ void wxEventLoop::Exit(int rc) // wxEventLoop message processing dispatching // ---------------------------------------------------------------------------- +extern bool g_isIdle; + bool wxEventLoop::Pending() const { - return gtk_events_pending() > 0; + if (wxTheApp && !g_isIdle) + { + // We need to remove idle callbacks or gtk_events_pending will + // never return false. + gtk_idle_remove( wxTheApp->m_idleTag ); + wxTheApp->m_idleTag = 0; + g_isIdle = TRUE; + } + + return gtk_events_pending(); } bool wxEventLoop::Dispatch()