Community
Participate
Working Groups
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB6; IPMS/7E13080A-14ADC08D3A3; TCO_20091019161107; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) Build Identifier: I20090611-1540 The removed 'IContributionItem' instances will reapear when any perspective resets. The 'cbItemsCreationOrder' referenced in org.eclipse.jface.action.CoolBarManager.resetItemOrder() could be added but couldn't be removed. Because itemAdded() is adding to the 'cbItemsCreationOrder' but itemRemoved() is doing nothing to the 'cbItemsCreationOrder'. Reproducible: Always Steps to Reproduce: 1. Add 'IContributionItem' instances to a CoolBarManager. 2. Remove some of them from the CoolBarManager. 3. Run the application and reset any perspective. 4. Now you can see the zombies.
Do you have an RCP app? Or are you a plugin in the IDE? How are you removing coolbar items? PW
(In reply to comment #1) > Do you have an RCP app? Or are you a plugin in the IDE? How are you removing > coolbar items? > PW I made not a plugin but a RCP application. And I removed not coolbar items but toolbar items as follows: ICoolBarManager cbm = coolBarManagers.get(page.getWorkbenchWindow()); IContributionItem[] items = cbm.getItems(); for (IContributionItem item : items) { if (item instanceof ToolBarContributionItem) { ToolBarContributionItem toolBarItem = (ToolBarContributionItem) item; cbm.remove(item); item.dispose(); } } When I traced the problem, I found the reason why this happened. 'org.eclipse.jface.action.CoolBarManager' class has a problem. itemAdded() method is: protected void itemAdded(IContributionItem item) { Assert.isNotNull(item); super.itemAdded(item); int insertedAt = indexOf(item); boolean replaced = false; final int size = cbItemsCreationOrder.size(); for (int i = 0; i < size; i++) { IContributionItem created = (IContributionItem) cbItemsCreationOrder .get(i); if (created.getId() != null && created.getId().equals(item.getId())) { cbItemsCreationOrder.set(i, item); replaced = true; break; } } if (!replaced) { cbItemsCreationOrder.add(Math.min(Math.max(insertedAt, 0), cbItemsCreationOrder.size()), item); } } And itemRemoved() method is: protected void itemRemoved(IContributionItem item) { Assert.isNotNull(item); super.itemRemoved(item); CoolItem coolItem = findCoolItem(item); if (coolItem != null) { coolItem.setData(null); } } itemAdded() method adds items to cbItemsCreationOrder, but itemRemoved() method doesn't removes any item from cbItemsCreationOrder. There is no problem unless resetting any perspective. But if any perspective is reset, the problem which i mentioned before will happen. Please check the implementation of resetItemOrder() method. It replaces CoolBarManager's items with the cbItemsCreationOrder which has the above problem.
(In reply to comment #2) > > ICoolBarManager cbm = coolBarManagers.get(page.getWorkbenchWindow()); > IContributionItem[] items = cbm.getItems(); This is not supported. i.e. in an RCP app, you cannot remove items from the coolbar while the workbench is running. You can only add items in your ActionBarAdvisor, or set an existing item (that you contributed yourself) to visible==false. But I'll leave this open since I think you're right, itemRemoved should undo what itemAdded does. PW
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.