Update table.go - Fixed a bug with concurrent access zu the maps for … #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…columns width and row heights
Description:
If a UpdateCell-func calls table.SetRowHeight() to adjust the height of the current row two problems arise.
This enforces a table.Refresh() which in turn executes a call to UpdateCell and could produce an infinite loop until the stack is exhausted. This can be prevented by a simple variable lock in the UpdateCell-func that avoids setting the RowHeight twice.
If that is fixed and a large table is scrolled it will run into a “concurrent map write” fatal error. This is because the ongoing updates run in parallel to UpdateCell-Calls and at some time a read of the map will happen in parallel to a write of the map.
I have fixed this problem, at least for my tests, by introducing a mutex that saveguards all accesses to the map. I have not savguarded the other maps, as they are no generating any errors. Hope this helps and would be glad to see this in the main branch.
Fixes fyne-io#5007
Checklist: