Minor optimization in wxGTK wxYield()

Don't call gdk_window_get_display() if we don't need it because we don't have
any events to put back into the display queue.
This commit is contained in:
Vadim Zeitlin 2016-06-05 00:55:20 +02:00
parent 1a438e786c
commit cc37031d46

View File

@ -385,16 +385,19 @@ void wxGUIEventLoop::DoYieldFor(long eventsToProcess)
wxEventLoopBase::DoYieldFor(eventsToProcess);
// put all unprocessed GDK events back in the queue
GdkDisplay* disp = gdk_window_get_display(wxGetTopLevelGDK());
for (size_t i=0; i<m_arrGdkEvents.GetCount(); i++)
// put any unprocessed GDK events back in the queue
if ( !m_arrGdkEvents.IsEmpty() )
{
GdkEvent* ev = (GdkEvent*)m_arrGdkEvents[i];
GdkDisplay* disp = gdk_window_get_display(wxGetTopLevelGDK());
for (size_t i=0; i<m_arrGdkEvents.GetCount(); i++)
{
GdkEvent* ev = (GdkEvent*)m_arrGdkEvents[i];
// NOTE: gdk_display_put_event makes a copy of the event passed to it
gdk_display_put_event(disp, ev);
gdk_event_free(ev);
// NOTE: gdk_display_put_event makes a copy of the event passed to it
gdk_display_put_event(disp, ev);
gdk_event_free(ev);
}
m_arrGdkEvents.Clear();
}
m_arrGdkEvents.Clear();
}