-
Notifications
You must be signed in to change notification settings - Fork 228
Skip dummy item creation when removing element from viewer twice #3525 #3527
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
Conversation
|
@laeubi This fixes the issue with the project explorer. Though I'd still like to add a proper test case. |
|
@ptziegler good finding! I can guess its hard to come of with a simple testcase here given JDT is involved and we likely do not want to include it as a dependency. |
|
Considering M3 is this week, I would prefer to postpone this change to 4.39 (assuming it works() in general and not only for specific use case). This change (which affects org.eclipse.jface.viewers.AbstractTreeViewer.remove(Object...)` behavior must be tested for a longer time before release. |
|
I had a closer look at Bug 210747 and whatever was done with f1899ad doesn't work, regardless of my change.
As it is, eclipse.platform.ui/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java Lines 3125 to 3127 in 39d028e
What a mess... |
652520a to
657b1b7
Compare
|
I've adapted the check so that for the use-case described in Bug 210747, where an element was removed from the tree that hasn't been realized yet, the I'm still not sure what the reasoning behind the initial change was, but I'm fairly confident that what was described in the bug was never fixed and probably can't be reasonbly fixed. I've added a test case for this bug, which will obviously fail. Perhaps someone who is more familiar with the TreeViewer can have a look, otherwise I'll remove it again for the next M1.
That's fine by me. This problem has existed for almost two decades, so three more months won't make much of a difference. |
|
I'm a little bit concerned about this code block here, which is also responsible for the test failure and which was added with #810 eclipse.platform.ui/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java Lines 2065 to 2084 in 601b0d3
In short, if |
ad4c5c7 to
562ad67
Compare
|
This pull request changes some projects for the first time in this development cycle. An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch. Git patchFurther information are available in Common Build Issues - Missing version increments. |
|
If there are no objections (and if the remaining checks succeed), I'll plan on merging this within the next few days. |
|
@ptziegler : not sure if the commit title & message, PR title & message are reflecting the actual fix? |
I can't reproduce on master, tried with Package and Project Explorers. Anything missing, like projects should be expanded / collapsed etc? Or is this only Windows specific (I'm on RHEL Linux/X11). |
|
This patch doesn't fix for me the problem with the steps above. |
Yes, the resource filter for files starting with a '.' needs to be enabled. Apologies for the inaccuracy.
On Linux, this block is entered, which then causes the creation of an additional tree item. But not on Windows. Commenting this block out makes the viewer behave as expected, but that shouldn't be the solution. eclipse.platform.ui/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java Lines 279 to 299 in 8b402ec
The call to eclipse.platform.ui/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewer.java Lines 176 to 179 in 8b402ec
|
So it looks like the patch works on Windows only? Have you Mac access, any idea how it looks there? Could you please investigate that Windows/Linux inconsistency before merging the patch? |
That seems to be the cases, yes.
No, only Windows and Linux.
That's my current plan. If this really is an SWT issue, it should be possible to derive a small snippet with the same, inconsistent "expanded" state. |
Can you please update commit message & rebase? |
…pse-platform#3525 Due to the fix for Bug 210747, a dummy tree-item is added to the viewer if the same element is removed twice. The intend of the original fix is to remove the "expand" icon from a tree item, when its still collapsed children are removed from the viewer (but not the model). The problem with this approach is that it doesn't take the situation into consideration, where the children of the item have already been removed. Given a tree item with at least one child in the data model but where all child-widgets have been removed in the viewer. When removing the children again, this internally calls `updatePlus(Item,Object)`. But because the number of child-widgets doesn't match the number of children, this method now creates a dummy item, to correct this inconsistency. This problem doesn't occur when calling `internalRemove(Object,Object[])`, because here the call to `updatePlus(Item,Object)` is guarded by a check to make sure the tree item has at least one child-widget. To reproduce: 1) Make sure the ".* resources" filter is enabled 2) Create a new project "Project A" and "Project B" 3) Create a new text file "test" in "Project A" 4) Move "test" to "Project B" Closes eclipse-platform#3525
|
@iloveeclipse I've updated the commit/pr message and elaborated a little bit on what exactly is going wrong and why. |
|
Thanks @ptziegler. Sorry for delay, as usually totally overloaded... |
|
No worries. Thanks for also taking a look at this change. Otherwise I completely would've missed the weird behavior on Linux. |



Due to the fix for Bug 210747, a dummy tree-item is added to the viewer if the same element is removed twice. The intend of the original fix is to remove the "expand" icon from a tree item, when its still collapsed children are removed from the viewer (but not the model).
The problem with this approach is that it doesn't take the situation into consideration, where the children of the item have already been removed.
Given a tree item with at least one child in the data model but where all child-widgets have been removed in the viewer. When removing the children again, this internally calls
updatePlus(Item,Object).But because the number of child-widgets doesn't match the number of children, this method now creates a dummy item, to correct this inconsistency. This problem doesn't occur when calling
internalRemove(Object,Object[]), because here the call toupdatePlus(Item,Object)is guarded by a check to make sure the tree item has at least one child-widget.To reproduce:
Closes #3525