Skip to content

Table passes negative index to onSelected function #4917

@samuelchristlie

Description

@samuelchristlie

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

Table would often randomly pass a negative value to the onSelected function and end up crashing the program. Based on my test, it always passes the correct digit but in negative and it can happen anytime between the first selection and after a couple dozens.

For example,

panic: runtime error: index out of range [-4]

was produced by

actionIdInt, _ := strconv.Atoi((*data)[id.Row][0])

The result of printing id.Row:

4
2
1
-2

Might be related to #2857

How to reproduce

  1. Create a table
  2. Set onSelected function that processes the selected row ID
  3. Click on random cells
  4. Negative value is passed

Screenshots

No response

Example code

table.OnSelected = func(id widget.TableCellID) {
		fmt.Println(id.Row)
		fmt.Println(id.Col)
		fmt.Println("")
}

Fyne version

v2.4.5

Go compiler version

1.22.3

Operating system and version

Linux Mint 21.3 x86_64

Additional Information

No response

Metadata

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