fix(openfsd-client): create install entry before client Select init

Select.SetSelected fires OnChanged immediately, which auto-detects and
calls installEntry.SetText. Building the entry after SetSelected panics
with a nil Entry on Windows GUI startup.
This commit is contained in:
Reese Norris
2026-07-29 12:04:40 -04:00
parent 363fa54601
commit e29e7cf45b

View File

@@ -99,6 +99,24 @@ func (c *controller) updateForm(fn func(*FormState)) {
}
func (c *controller) buildUI() fyne.CanvasObject {
// --- Install path first ---
// Client Select.SetSelected runs OnChanged immediately and may call onDetect,
// which writes installEntry. Creating the entry after SetSelected panics
// (nil *widget.Entry.SetText) — observed on Windows GUI boot.
c.installEntry = widget.NewEntry()
c.installEntry.SetPlaceHolder("Client folder")
c.installEntry.OnChanged = func(s string) {
c.updateForm(func(f *FormState) { f.InstallPath = s })
}
c.detectBtn = widget.NewButton("Detect", func() { c.onDetect(true) })
browseBtn := widget.NewButton("Browse…", func() {
c.onBrowse()
})
installRow := container.NewBorder(nil, nil, nil,
container.NewHBox(c.detectBtn, browseBtn),
c.installEntry,
)
// --- Client (enabled only) ---
var labels []string
var firstEnabled string
@@ -130,21 +148,6 @@ func (c *controller) buildUI() fyne.CanvasObject {
}
}
// --- Install path ---
c.installEntry = widget.NewEntry()
c.installEntry.SetPlaceHolder("Client folder")
c.installEntry.OnChanged = func(s string) {
c.updateForm(func(f *FormState) { f.InstallPath = s })
}
c.detectBtn = widget.NewButton("Detect", func() { c.onDetect(true) })
browseBtn := widget.NewButton("Browse…", func() {
c.onBrowse()
})
installRow := container.NewBorder(nil, nil, nil,
container.NewHBox(c.detectBtn, browseBtn),
c.installEntry,
)
// --- Endpoints ---
c.webBaseEntry = widget.NewEntry()
c.webBaseEntry.SetPlaceHolder("https://fsd.example.com")
@@ -305,6 +308,9 @@ func (c *controller) setBusy(v bool) {
}
func (c *controller) onDetect(showMiss bool) {
if c.installEntry == nil {
return
}
f := c.formCopy()
cand, ok := FirstDetectPath(c.eng, f.ClientID)
if !ok {