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
+10 -4
View File
@@ -321,12 +321,18 @@ func (c *pointerCollector) offerOp(op transfer.OfferOp, events *handlerEvents) {
h.data = op.Data
}
func (c *pointerCollector) reset(q *pointerQueue) {
q.reset()
func (c *pointerCollector) reset() {
c.q.reset()
c.resetState()
c.nodeStack = c.nodeStack[:0]
c.q = q
// Add implicit root area for semantic descriptions to hang onto.
c.ensureRoot()
}
// Ensure implicit root area for semantic descriptions to hang onto.
func (c *pointerCollector) ensureRoot() {
if len(c.q.areas) > 0 {
return
}
c.pushArea(areaRect, f32.Rect(-1e6, -1e6, 1e6, 1e6))
// Make it semantic to ensure a single semantic root.
c.q.areas[0].semantic.valid = true