New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segfault when adding items directly in form struct #3153
Comments
Please provide the crash trace |
With the example code: package main
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()
}
func main() {
start(true)
} I get:
|
The crash happens because Line 221 in 638ae24
|
This was fixed ready for next release |
Checklist
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 noform.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
Fyne version
v2.2.3
Go compiler version
go1.18.4
Operating system
macOS
Operating system version
11.6.5
Additional Information
No response
The text was updated successfully, but these errors were encountered: