summaryrefslogtreecommitdiff
path: root/Libraries/LibCore/CEventLoop.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-25 16:12:51 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-25 16:12:51 +0200
commitd21a4f7518ced2b49e20b3b2521c80b0afec216d (patch)
tree1b6ba5fff95e12a5e0a73fe0b6fc99b3f897a94f /Libraries/LibCore/CEventLoop.cpp
parent3363426a6ba0a9b27302ec15cbf6c6e5af490a52 (diff)
downloadserenity-d21a4f7518ced2b49e20b3b2521c80b0afec216d.zip
CEventLoop: Don't re-process already processed events when un-nesting.
If we had already processed a couple of queued events by the time we were told to un-nest the event loop, we'd put the entire current batch at the head of the outer queue. This meant that we might end up trying to process the same events multiple times. Let's not do that. :^)
Diffstat (limited to 'Libraries/LibCore/CEventLoop.cpp')
-rw-r--r--Libraries/LibCore/CEventLoop.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/Libraries/LibCore/CEventLoop.cpp b/Libraries/LibCore/CEventLoop.cpp
index 719e136950..54b1830406 100644
--- a/Libraries/LibCore/CEventLoop.cpp
+++ b/Libraries/LibCore/CEventLoop.cpp
@@ -141,8 +141,12 @@ void CEventLoop::pump(WaitMode mode)
if (m_exit_requested) {
LOCKER(m_lock);
- // FIXME: Shouldn't we only prepend the events that haven't been processed yet?
- m_queued_events.prepend(move(events));
+ decltype(m_queued_events) new_event_queue;
+ new_event_queue.ensure_capacity(m_queued_events.size() + events.size());
+ for (; i < events.size(); ++i)
+ new_event_queue.unchecked_append(move(events[i]));
+ new_event_queue.append(move(m_queued_events));
+ m_queued_events = move(new_event_queue);
return;
}
}