io/router: don't panic for nil op.Ops arguements to Router.Frame

Fixes gio#306

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-11-10 13:24:17 +01:00
parent 5ddd572a41
commit 303b819539
2 changed files with 11 additions and 2 deletions
+5
View File
@@ -220,6 +220,11 @@ func TestKeyFocusedInvisible(t *testing.T) {
}
func TestNoOps(t *testing.T) {
r := new(Router)
r.Frame(nil)
}
func assertKeyEvent(t *testing.T, events []event.Event, expected bool, expectedInputs ...event.Event) {
t.Helper()
var evtFocus int
+6 -2
View File
@@ -68,13 +68,17 @@ func (q *Router) Events(k event.Tag) []event.Event {
// Frame replaces the declared handlers from the supplied
// operation list. The text input state, wakeup time and whether
// there are active profile handlers is also saved.
func (q *Router) Frame(ops *op.Ops) {
func (q *Router) Frame(frame *op.Ops) {
q.handlers.Clear()
q.wakeup = false
for k := range q.profHandlers {
delete(q.profHandlers, k)
}
q.reader.Reset(&ops.Internal)
var ops *ops.Ops
if frame != nil {
ops = &frame.Internal
}
q.reader.Reset(ops)
q.collect()
q.pointer.queue.Frame(&q.handlers)