app: ensure derived events are processed

A range loop may not see all items in a slice that is appended to during
iteration. Convert range loop to popping each event off the queue until
it is empty.

Fixes: https://todo.sr.ht/~eliasnaur/gio/356
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-02-06 11:21:00 +01:00
parent 44c9fb7448
commit 9d778d7bde
+4 -2
View File
@@ -423,10 +423,12 @@ func (c *callbacks) Event(e event.Event) {
defer func() {
c.busy = false
}()
for _, e := range c.waitEvents {
for len(c.waitEvents) > 0 {
e := c.waitEvents[0]
copy(c.waitEvents, c.waitEvents[1:])
c.waitEvents = c.waitEvents[:len(c.waitEvents)-1]
c.w.processEvent(c.d, e)
}
c.waitEvents = c.waitEvents[:0]
c.w.updateState(c.d)
if c.w.closing {
c.w.closing = false