Fix several segfaults

This commit is contained in:
Sasha Koshka 2024-06-03 01:51:43 -04:00
parent c3050e258f
commit 3e1a3ea5b9
3 changed files with 11 additions and 4 deletions

View File

@ -215,7 +215,7 @@ func (this *box) SetFocusable (focusable bool) {
} }
func (this *box) Focused () bool { func (this *box) Focused () bool {
hierarchy := this.parent.getHierarchy() hierarchy := this.getHierarchy()
if hierarchy == nil { return false } if hierarchy == nil { return false }
return hierarchy.isFocused(this) return hierarchy.isFocused(this)
} }

View File

@ -50,8 +50,11 @@ type WindowLink interface {
// NewHierarchy creates a new Hierarchy. // NewHierarchy creates a new Hierarchy.
func (this *System) NewHierarchy (link WindowLink) *Hierarchy { func (this *System) NewHierarchy (link WindowLink) *Hierarchy {
hierarchy := &Hierarchy { hierarchy := &Hierarchy {
system: this, system: this,
link: link, link: link,
needMinimum: make(util.Set[anyBox]),
needLayout: make(util.Set[anyBox]),
needDraw: make(util.Set[anyBox]),
} }
return hierarchy return hierarchy
} }

View File

@ -164,7 +164,11 @@ func (this *Backend) newWindow (
} }
func (this *window) SetRoot (root tomo.Object) { func (this *window) SetRoot (root tomo.Object) {
this.hierarchy.SetRoot(root.GetBox()) if root == nil {
this.hierarchy.SetRoot(nil)
} else {
this.hierarchy.SetRoot(root.GetBox())
}
} }
func (this *window) SetTitle (title string) { func (this *window) SetTitle (title string) {