You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a (SWT.VIRTUAL) TableViewer and in certain constellations the second and all subsequent setSelections select the wrong entry.
Create a (SWT.VIRTUAL) TableViewer (new LabelProvider(), ArrayContentProvider.getInstance())
Add 100 entries to the table with TableViewer.setInput
TableViewer.setSelection to the 4th entry (referring to the original input)
The correct entry is selected
Now add a filter to the TableViewer so that only the 3rd, 4th, 5th and 6th entries (referring to the original input) are left
TableViewer.setSelection to the 4th entry (referring to the original input)
Now: From the resulting 4 rows the second row should be selected, instead the 6th is selected
The Problems occurs because Step 5 executes a "clear" on all TableItems but this clear keeps the Widget.data field value intact and the original 4th items seems to be recycled for the new 6th item. So when Step 6 searchs for a matching Item it finds the wrong TableItem by comparing the 'new Selection' with the TableItem.getData (method from Widget)
(edit 2022-09-29 @mknauer: Attached referenced ZIP archive as Issue 57.zip to this issue)
Just open the web app and watch the Console. I've tried to keep the project as simple as possible (no fancy code) and to describe the problem with the comments within the code and in the console output. All the relevant code is in the class View.
I've fixed the issue by extending the clear method on TableItem but I don't know if this is a valid fix but would result in other problems:
final void clear() {
data = null;
checked = false;
grayed = false;
parent.updateScrollBars();
if ((parent.style & SWT.VIRTUAL) != 0) {
cached = false;
setData(null); // <= added this line
parent.redraw();
}
}
Attention: The described fix does NOT work with TableViewer.setUseHashlookup(true)!
The text was updated successfully, but these errors were encountered:
jfuerter
changed the title
The second (and further) setSelection on a filtered virtual TableViewer selects the wrong row/entry
The second (and all subsequent) setSelection on a filtered virtual TableViewer selects the wrong row/entry
Sep 27, 2022
We have a (
SWT.VIRTUAL
)TableViewer
and in certain constellations the second and all subsequentsetSelection
s select the wrong entry.Here a simple project to reproduce the issue:
https://we.tl/t-s0uMT7MLpG
Just open the web app and watch the Console. I've tried to keep the project as simple as possible (no fancy code) and to describe the problem with the comments within the code and in the console output. All the relevant code is in the class
View
.I've fixed the issue by extending the
clear
method onTableItem
but I don't know if this is a valid fix but would result in other problems:Attention: The described fix does NOT work with TableViewer.setUseHashlookup(true)!
The text was updated successfully, but these errors were encountered: