| Summary: | [Viewers] - Lazy Virtual Table View Test - duplicate items appear after delete | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Susan McCourt <susan> | ||||
| Component: | UI | Assignee: | Boris Bokowski <bokowski> | ||||
| Status: | VERIFIED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | bpasero, david.perez.ingeniero, eclipse.sprigogin, mlists, ovidr, tom.schindl | ||||
| Version: | 3.1 | Keywords: | api, helpwanted | ||||
| Target Milestone: | 3.5 M3 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | contained | ||||||
| Bug Depends on: | |||||||
| Bug Blocks: | 154755 | ||||||
| Attachments: |
|
||||||
|
Description
Susan McCourt
The reason for the strange behaviour is that clicking the delete button does not update the underlying model, it only calls remove() on the viewer. While trying to fix the Lazy Virtual Table View Test I noticed a bug in TableViewer.remove. In the VIRTUAL case, preservingSelection() may end up calling the content provider for an index that no longer exists, potentially causing an AIOOBE. *** Bug 112411 has been marked as a duplicate of this bug. *** Sorry, I ran out of time for M4 - moving to M5. One solution for TableViewer would be to not use preservingSelection() if we are removing elements from a virtual table. Instead, we could remember the selected indices, update them based on the indices of the elements being removed, and then setting the selection back using the updated indices. There will be a similar problem for the virtual tree, and the index-based magic would be way more complicated for trees. I don't know what the best answer is. Another solution would be to introduce a new method that is called whenever we need an updated item count.
I'm considering deprecating ILazyContentProvider and introducing a replacement (possibly IVirtualTableContentProvider) with a new method as follows:
/**
* Called when there is a chance that the item count needs to
* be updated, namely from {@link TableViewer#refresh()} and
* {@link TableViewer#setInput(Object)}. The content provider
* should respond by calling {@link TableViewer#setItemCount(int)}.
*/
public void updateItemCount();
Sorry, I ran out of time again. I don't know why, but higher priority items seem to prevent me from fixing this. Where from do I get the mentionned test cases? Are they somewhere in CVS? (In reply to comment #7) > I don't know why, but higher priority items seem to prevent me from fixing > this. > Bug 112411 has an attached test case. The LazyVirtualTableView test class can be found in CVS in the plug-in org.eclipse.ui.tests. To run the test cases you will also need the plug-ins org.eclipse.core.tests.boot, org.eclipse.core.tests.harness, and org.eclipse.test.performance. (In reply to comment #10) > The LazyVirtualTableView test class can be found in CVS in the plug-in > org.eclipse.ui.tests. To run the test cases you will also need the plug-ins > org.eclipse.core.tests.boot, org.eclipse.core.tests.harness, and > org.eclipse.test.performance. > Ok. I've got them and try to run the "JUnit"-Test but they fail with "Unsatisfied LinkError" do I need to set the swt.dll myself when start those test. Run As->JUnit Plug-in Test (In reply to comment #12) > Run As->JUnit Plug-in Test > Thanks figured it out myself. But the test I'm trying too launch is one of the interactive ones there's no Run As->JUnit Plug-in Test|Junit I needed to start the workbench-plugin and select the view ;-) Thanks Tom Mass update - removing 3.4 target. This was one of the bugs I marked for investigation (and potential fixing) in 3.4 but I ran out of time. Please ping on the bug if fixing it would be really important for 3.4, and does not require API changes or feature work. Is there any plan to solve such an old bug in such a basic GUI class as TableViewer for such a usual operation as delete an item? Is there any known workaround? I have created a CRUD editor based on TableViewer, and I observe this bug nearly always I try to delete an item. I believe the workaround is to empty the selection before you delete the element. I can mark this for investigation in 3.5 but am not sure if I will have the time if there is no easy fix. Confirmed that this workaround works! Until the bug isn't solved, it would be good to unselect in the Viewer.remove() method. My CRUD framework based on JFace/SWT is working quite well. :-) Created attachment 112591 [details]
patch
I would like to avoid releasing this patch so close to M2. Moving to M3. Released to HEAD. Verified by code inspection using I20081028-0100, and by using the steps from comment 0. |