From 3e1a3ea5b9dae679e752903f7faaacb46cbb72c7 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Mon, 3 Jun 2024 01:51:43 -0400 Subject: [PATCH] Fix several segfaults --- internal/system/box.go | 2 +- internal/system/hierarchy.go | 7 +++++-- x/window.go | 6 +++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/internal/system/box.go b/internal/system/box.go index 525c054..e419246 100644 --- a/internal/system/box.go +++ b/internal/system/box.go @@ -215,7 +215,7 @@ func (this *box) SetFocusable (focusable bool) { } func (this *box) Focused () bool { - hierarchy := this.parent.getHierarchy() + hierarchy := this.getHierarchy() if hierarchy == nil { return false } return hierarchy.isFocused(this) } diff --git a/internal/system/hierarchy.go b/internal/system/hierarchy.go index 564df79..cc1b059 100644 --- a/internal/system/hierarchy.go +++ b/internal/system/hierarchy.go @@ -50,8 +50,11 @@ type WindowLink interface { // NewHierarchy creates a new Hierarchy. func (this *System) NewHierarchy (link WindowLink) *Hierarchy { hierarchy := &Hierarchy { - system: this, - link: link, + system: this, + link: link, + needMinimum: make(util.Set[anyBox]), + needLayout: make(util.Set[anyBox]), + needDraw: make(util.Set[anyBox]), } return hierarchy } diff --git a/x/window.go b/x/window.go index a911b81..49eecd0 100644 --- a/x/window.go +++ b/x/window.go @@ -164,7 +164,11 @@ func (this *Backend) newWindow ( } 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) {