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

GUI: wx.ListBox is dynamic – looping over GetSelections() results in removal of all list items #2511

Merged
merged 2 commits into from
Aug 5, 2022

Conversation

marisn
Copy link
Contributor

@marisn marisn commented Aug 4, 2022

When the last item returned by GetSelections() has been .Delete()'d a new item is selected. The newly selected item is added to GetSelections(). If user selects the last item from a list, looping over GetSelections() output eventually will remove all list items not only ones selected by the user.
This is a workaround by freezing user selection in a list and iterating it in a reverse order as each .Delete() call updates the ListBox and thus changes positions of selected items. Reverse traversal ensures that no selected item gets a new position in the list.

…removal of all list items

When the last item returned by GetSelections() has been .Delete()'d a new item is selected. The newly selected item is added to GetSelections(). If user selects the last item from a list, looping over GetSelections() output eventually will remove all list items not only ones selected by the user.
This is a workaround by freezing user selection in a list and iterating it in a reverse order as each .Delete() call updates the ListBox and thus changes positions of selected items. Reverse traversal ensures that no selected item gets a new position in the list.
@marisn marisn requested a review from wenzeslaus August 4, 2022 13:33
@marisn marisn added the GUI wxGUI related label Aug 4, 2022
@marisn marisn added this to the 8.4.0 milestone Aug 4, 2022
@wenzeslaus wenzeslaus requested review from tmszi and removed request for wenzeslaus August 4, 2022 13:53
@wenzeslaus
Copy link
Member

@tmszi can probably handle this better!

gui/wxpython/gui_core/dialogs.py Outdated Show resolved Hide resolved
@tmszi tmszi added bug Something isn't working backport_needed labels Aug 5, 2022
@tmszi tmszi modified the milestones: 8.4.0, 8.2.1 Aug 5, 2022
@marisn marisn merged commit 2f7e14a into OSGeo:main Aug 5, 2022
marisn added a commit that referenced this pull request Aug 7, 2022
#2511)

* GUI: wx.ListBox is dynamic – looping over GetSelections() results in removal of all list items

When the last item returned by GetSelections() has been .Delete()'d a new item is selected. The newly selected item is added to GetSelections(). If user selects the last item from a list, looping over GetSelections() output eventually will remove all list items not only ones selected by the user.
This is a workaround by freezing user selection in a list and iterating it in a reverse order as each .Delete() call updates the ListBox and thus changes positions of selected items. Reverse traversal ensures that no selected item gets a new position in the list.
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Oct 26, 2022
OSGeo#2511)

* GUI: wx.ListBox is dynamic – looping over GetSelections() results in removal of all list items

When the last item returned by GetSelections() has been .Delete()'d a new item is selected. The newly selected item is added to GetSelections(). If user selects the last item from a list, looping over GetSelections() output eventually will remove all list items not only ones selected by the user.
This is a workaround by freezing user selection in a list and iterating it in a reverse order as each .Delete() call updates the ListBox and thus changes positions of selected items. Reverse traversal ensures that no selected item gets a new position in the list.
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
OSGeo#2511)

* GUI: wx.ListBox is dynamic – looping over GetSelections() results in removal of all list items

When the last item returned by GetSelections() has been .Delete()'d a new item is selected. The newly selected item is added to GetSelections(). If user selects the last item from a list, looping over GetSelections() output eventually will remove all list items not only ones selected by the user.
This is a workaround by freezing user selection in a list and iterating it in a reverse order as each .Delete() call updates the ListBox and thus changes positions of selected items. Reverse traversal ensures that no selected item gets a new position in the list.
neteler pushed a commit to nilason/grass that referenced this pull request Nov 7, 2023
OSGeo#2511)

* GUI: wx.ListBox is dynamic – looping over GetSelections() results in removal of all list items

When the last item returned by GetSelections() has been .Delete()'d a new item is selected. The newly selected item is added to GetSelections(). If user selects the last item from a list, looping over GetSelections() output eventually will remove all list items not only ones selected by the user.
This is a workaround by freezing user selection in a list and iterating it in a reverse order as each .Delete() call updates the ListBox and thus changes positions of selected items. Reverse traversal ensures that no selected item gets a new position in the list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working GUI wxGUI related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants