Skip to content

stack overflow when calling SetRowHeight in table UpdateCell callback #5007

Closed
JanVaya/fyne
#1
@MidnightSong

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 create a table widget . But the row height is uncertain when it created, only until use other variable return fields.

runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0x1407a780420 stack=[0x1407a780000, 0x1409a780000]
fatal error: stack overflow

runtime stack:
runtime.throw({0x104b739ce?, 0x16ee4adb8?})
/usr/local/go/src/runtime/panic.go:1023 +0x40 fp=0x16ee4ad50 sp=0x16ee4ad20 pc=0x103016420
runtime.newstack()
/usr/local/go/src/runtime/stack.go:1103 +0x478 fp=0x16ee4aef0 sp=0x16ee4ad50 pc=0x103030fa8
runtime.morestack()
/usr/local/go/src/runtime/asm_arm64.s:341 +0x70 fp=0x16ee4aef0 sp=0x16ee4aef0 pc=0x103049010

goroutine 115 gp=0x1400f26ce00 m=5 mp=0x14000100008 [running]:
fyne.io/fyne/v2/widget.splitLines(0x140002491f0)
/Users/xjy/go/pkg/mod/fyne.io/fyne/[email protected]/widget/richtext.go:1097 +0x3e8 fp=0x1407a780420 sp=0x1407a780420 pc=0x104999418
fyne.io/fyne/v2/widget.lineBounds(0x140002491f0, 0x0, 0x0, 0x436a0000, {0x436a0000, 0x4193e000}, 0x1407a780be8)
/Users/xjy/go/pkg/mod/fyne.io/fyne/[email protected]/widget/richtext.go:943 +0x54 fp=0x1407a780a20 sp=0x1407a780420 pc=0x104997714
fyne.io/fyne/v2/widget.(*RichText).updateRowBounds.func1({0x140104a03f0, 0x1, 0x1})

when i remove this code :

table.SetRowHeight(id.Row, 50).

Everything has become normal

How to reproduce

just use i provide code

Screenshots

Longshot-20240718234817

Example code

when i use this code:

package main

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/widget"
)

var data = [][]string{
	{"this is a long string", "Row 1, Col 2"},
	{"Row 2, Col 1", "Row 2, Col 2"},
	{"Row 3, Col 1", "Row 3, Col 2"},
	{"Row 4, Col 1", "Row 4, Col 2"},
	{"Row 5, Col 1", "Row 5, Col 2"},
	{"Row 6, Col 1", "Row 6, Col 2"},
}

func main() {
	mainApp := app.NewWithID("a.b.c.d")
	mainWin := mainApp.NewWindow("test table")
	table := getTable()
	mainWin.SetContent(container.NewStack(table))
	mainWin.CenterOnScreen()
	mainWin.Resize(fyne.NewSize(600, 400))
	mainWin.ShowAndRun()
}

func getTable() *widget.Table {
	var table *widget.Table
	table = widget.NewTableWithHeaders(func() (int, int) { return len(data), 2 },
		func() fyne.CanvasObject {
			label := widget.NewLabel("unload")
			return label
		},
		func(id widget.TableCellID, cell fyne.CanvasObject) {
			c := cell.(*widget.Label)
			if len(data[id.Row][id.Col]) > 10 {
				table.SetRowHeight(id.Row, 50)
			}
			c.SetText(data[id.Row][id.Col])
		},
	)
	table.SetColumnWidth(0, 100)
	table.SetColumnWidth(1, 100)
	return table
}

Fyne version

v2.5.0

Go compiler version

1.21

Operating system and version

macOS Sonoma 14.5 Apple M2

Additional Information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions