Don't generate idle events when the event loop is not running

This commit is contained in:
Graham Dawes
2019-01-21 14:53:43 +00:00
parent 278f4fa1d6
commit 7fa7fd1beb
2 changed files with 10 additions and 3 deletions

View File

@@ -24,6 +24,8 @@ public:
virtual void WakeUp() wxOVERRIDE;
virtual void DoYieldFor(long eventsToProcess) wxOVERRIDE;
void ScheduleIdleCheck();
#if wxUSE_EVENTLOOP_SOURCE
virtual wxEventLoopSource *AddSourceForFD(int fd, wxEventLoopSourceHandler *handler, int flags);
#endif // wxUSE_EVENTLOOP_SOURCE

View File

@@ -40,14 +40,13 @@ wxQtIdleTimer::wxQtIdleTimer( wxQtEventLoopBase *eventLoop )
connect( this, &QTimer::timeout, this, &wxQtIdleTimer::idle );
setSingleShot( true );
start( 0 );
}
bool wxQtIdleTimer::eventFilter( QObject *WXUNUSED( watched ), QEvent *WXUNUSED( event ) )
{
// Called for each Qt event, start with timeout 0 (run as soon as idle)
if ( !isActive() )
start( 0 );
m_eventLoop->ScheduleIdleCheck();
return false; // Continue handling the event
}
@@ -60,7 +59,7 @@ void wxQtIdleTimer::idle()
// Send idle event
if ( m_eventLoop->ProcessIdle() )
start( 0 );
m_eventLoop->ScheduleIdleCheck();
}
wxQtEventLoopBase::wxQtEventLoopBase()
@@ -147,6 +146,12 @@ void wxQtEventLoopBase::DoYieldFor(long eventsToProcess)
wxEventLoopBase::DoYieldFor(eventsToProcess);
}
void wxQtEventLoopBase::ScheduleIdleCheck()
{
if ( IsInsideRun() )
m_qtIdleTimer->start(0);
}
#if wxUSE_EVENTLOOP_SOURCE
template <void (wxEventLoopSourceHandler::*function)()>