Skip to content
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

Table passes negative index to onSelected function #4917

Open
2 tasks done
samuelchristlie opened this issue Jun 6, 2024 · 5 comments
Open
2 tasks done

Table passes negative index to onSelected function #4917

samuelchristlie opened this issue Jun 6, 2024 · 5 comments
Labels
unverified A bug that has been reported but not verified

Comments

@samuelchristlie
Copy link

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

@samuelchristlie samuelchristlie added the unverified A bug that has been reported but not verified label Jun 6, 2024
@andydotxyz
Copy link
Member

Are you certain it's 2.4.5 you are using?

@samuelchristlie
Copy link
Author

Yep, that's what it says on my go.mod

@andydotxyz
Copy link
Member

Out of interest is this fast tapping randomly anywhere in the table, or is this carefully tapping always inside the cell widget contents? (trying to understand if this might be a regression rather than new issue)

@andydotxyz
Copy link
Member

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

Can you please provide the full stack so we can see how it was triggered?

@samuelchristlie
Copy link
Author

samuelchristlie commented Jun 8, 2024

Out of interest is this fast tapping randomly anywhere in the table, or is this carefully tapping always inside the cell widget contents? (trying to understand if this might be a regression rather than new issue)

Both fast and slow taps triggered the error in my case, though I didn't really pay attention whether it was inside the cell. I don't have access to the code until Monday, but I'll do further tests once I can.

Can you please provide the full stack so we can see how it was triggered?

That error comes from my function trying to read the selected row. If I simply printed the id, no error occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified A bug that has been reported but not verified
Projects
None yet
Development

No branches or pull requests

2 participants