Closed
Description
Checklist
- I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
- This issue only relates to a single bug. I will open new issues for any other problems.
Describe the bug
I get a SEGFAULT when calling .Refresh()
on a form where all items were all added in the struct creation.
I followed this example, but added everything as Items
when creating the struct -- so no form.Append()
.
This issue may be the same as #1967, but I'm not sure.
The problem seems to be when ensureRenderItems assumes itemGrid
is not null. This is not the case when adding items directly to the form struct.
If adding items directly is not recommended, maybe the tutorial could be updated.
But a guard on this code would probably be safer.
How to reproduce
Call start(false)
on the example code below and it works fyne.
Call start(true)
on and it segfaults.
Screenshots
No response
Example code
import (
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/widget"
)
func start(segfault bool) {
a := app.New()
w := a.NewWindow("Manny")
name := widget.NewEntry()
name.SetPlaceHolder("John Smith")
item := &widget.FormItem{Text: "Name", Widget: name}
form := &widget.Form{}
if segfault {
form.Items = []*widget.FormItem{item}
} else {
form.AppendItem(item)
}
form.Refresh()
w.SetContent(form)
w.ShowAndRun()
}
Fyne version
v2.2.3
Go compiler version
go1.18.4
Operating system
macOS
Operating system version
11.6.5
Additional Information
No response
Activity