io/router: don't panic if AppendSemantics is called without a frame

Fixes: https://todo.sr.ht/~eliasnaur/gio/328
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-12-30 10:23:23 +01:00
parent 6913c856a2
commit cce0a121e1
3 changed files with 22 additions and 5 deletions
+4 -1
View File
@@ -183,13 +183,16 @@ func (q *Router) SemanticAt(pos f32.Point) (SemanticID, bool) {
// AppendSemantics appends the semantic tree to nodes, and returns the result.
// The root node is the first added.
func (q *Router) AppendSemantics(nodes []SemanticNode) []SemanticNode {
q.pointer.collector.q = &q.pointer.queue
q.pointer.collector.ensureRoot()
return q.pointer.queue.AppendSemantics(nodes)
}
func (q *Router) collect() {
q.transStack = q.transStack[:0]
pc := &q.pointer.collector
pc.reset(&q.pointer.queue)
pc.q = &q.pointer.queue
pc.reset()
kc := &q.key.collector
*kc = keyCollector{q: &q.key.queue}
q.key.queue.Reset()