Bug 571438

Summary: Contributed menu appears multiple times
Product: [Eclipse Project] Platform Reporter: Wim Jongman <wim.jongman>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: rolf.theunissen
Version: 4.19   
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
Whiteboard:
Bug Depends on:    
Bug Blocks: 562497    
Attachments:
Description Flags
Duplicate elements with model spy none

Description Wim Jongman CLA 2021-02-23 10:47:15 EST
Created attachment 285640 [details]
Duplicate elements with model spy

I have contributed a menu through a fragment. Whenever I forcefully quit the application, the menu entry lingers and gets added again on restart. 

The model needs to be refreshed before the entries appear. The menu entries all have the same element id.
Comment 1 Wim Jongman CLA 2021-02-23 10:52:44 EST
> The model needs to be refreshed before the entries appear.

I mean before the entries disappear.
Comment 2 Rolf Theunissen CLA 2021-02-24 02:47:30 EST
What do you mean by 'refresh the model'?

If it is removing the workbench.xmi file, its related to Bug 549902. The contributions might get cleaned on shutdown, but are persisted in the auto-saved version. Also Bug 440030 could add something in the mix.
Comment 3 Wim Jongman CLA 2021-02-24 04:07:05 EST
(In reply to Rolf Theunissen from comment #2)
> What do you mean by 'refresh the model'?

Yes, good one. I have found that the model can be 'refreshed' by using Window/New Window. That window is populated by a fresh copy of the workbench.

Then if you close the first window and restart, the model can catch up with the extension point and is cleaned up. 

> 
> If it is removing the workbench.xmi file, its related to Bug 549902. The
> contributions might get cleaned on shutdown, but are persisted in the
> auto-saved version. Also Bug 440030 could add something in the mix.

I will look into that, thanks.

In general, it is odd that multiple elements with the same element id can exist under the same parent.
Comment 4 Rolf Theunissen CLA 2021-02-24 06:03:49 EST
AFAIK, there is no validation or requirement that elements cannot have the same identifier, even if they are in the same container. Though, most likely there can be strange behavior (i.e. bugs) if two elements have the same identifier (even if they are in different containers and of different tyep) see e.g. Bug 562472.
All elements should have a unique UUID, although even that requirement is violated, see Bug 550272.

However, it does sound like a good requirement to have unique identifiers for children in a container. Maybe some consistency engine should (live model validation) could be added for this, or uniqueness checks could be added. EMF keys on (containment) references come to mind here. Although identifiers are not mandatory now, maybe the UUID can be used as fallback if the identifier is not set.