mirror of
https://github.com/renorris/openfsd
synced 2026-08-12 12:25:40 +08:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user