Bug 571438 - Contributed menu appears multiple times
Summary: Contributed menu appears multiple times
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.19   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 562497
  Show dependency tree
 
Reported: 2021-02-23 10:47 EST by Wim Jongman CLA
Modified: 2021-02-24 06:03 EST (History)
1 user (show)

See Also:


Attachments
Duplicate elements with model spy (58.99 KB, image/png)
2021-02-23 10:47 EST, Wim Jongman CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.