Fix some segfaults

This commit is contained in:
Sasha Koshka 2024-07-25 18:17:43 -04:00
parent a62dff4236
commit 5864c74691
2 changed files with 10 additions and 6 deletions

View File

@ -69,6 +69,7 @@ func (this *System) newBox (outer anyBox) *box {
system: this, system: this,
outer: outer, outer: outer,
drawer: outer, drawer: outer,
tags: make(util.Set[string]),
} }
box.canvas = util.NewMemo (func () canvas.Canvas { box.canvas = util.NewMemo (func () canvas.Canvas {
if box.parent == nil { return nil } if box.parent == nil { return nil }
@ -614,7 +615,8 @@ func (this *box) propagateAlt (callback func (anyBox) bool) bool {
func (this *box) transparent () bool { func (this *box) transparent () bool {
// TODO uncomment once we have // TODO uncomment once we have
// a way to detect texture transparency // a way to detect texture transparency
return util.Transparent(this.attrColor.Value()) /*&& col := this.attrColor.Value().Color
return col == nil || util.Transparent(col) /*&&
(this.texture == nil || !this.texture.Opaque())*/ (this.texture == nil || !this.texture.Opaque())*/
} }

View File

@ -11,7 +11,7 @@ type styleApplicator struct {
func (this *styleApplicator) apply (box anyBox) { func (this *styleApplicator) apply (box anyBox) {
if box.Role() != this.role { if box.Role() != this.role {
// the role has changed, so re-cache the list of rules // the role has changed, so re-cache the list of rules
this.rules = make([]*tomo.Rule, 4) this.rules = make([]*tomo.Rule, 0, 4)
for _, rule := range this.style.Rules { for _, rule := range this.style.Rules {
role := box.Role() role := box.Role()
// blank fields match anything // blank fields match anything
@ -27,10 +27,12 @@ func (this *styleApplicator) apply (box anyBox) {
attrs := make(tomo.AttrSet) attrs := make(tomo.AttrSet)
for _, rule := range this.rules { for _, rule := range this.rules {
satisifed := true satisifed := true
for _, tag := range rule.Tags { if rule.Tags != nil {
if !box.Tag(tag) { for _, tag := range rule.Tags {
satisifed = false if !box.Tag(tag) {
break satisifed = false
break
}
} }
} }