This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 432847 - [Contributions] Duplicate view toolbar buttons; menu enablement problems in Git Repositories view
Summary: [Contributions] Duplicate view toolbar buttons; menu enablement problems in G...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows 7
: P1 critical (vote)
Target Milestone: 4.4 M7   Edit
Assignee: Daniel Rolka CLA
QA Contact: Daniel Rolka CLA
URL:
Whiteboard:
Keywords:
: 432637 (view as bug list)
Depends on:
Blocks: 432637
  Show dependency tree
 
Reported: 2014-04-15 13:03 EDT by Markus Keller CLA
Modified: 2014-05-12 13:12 EDT (History)
8 users (show)

See Also:


Attachments
The XMI (8.42 KB, application/octet-stream)
2014-04-24 00:10 EDT, Louis-Michel Mathurin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2014-04-15 13:03:04 EDT
I20140408-1645 and I20140415-0800

Seems to work fine for me up to I20140402-0100, but others have had it earlier (bug 394505, bug 397064).

- new install of SDK, new workspace (important, since E4 seems to cache stuff across workspaces)
- Help > Install New Software..., use http://download.eclipse.org/egit/updates or Add... > Archive... and use a local copy of http://www.eclipse.org/downloads/download.php?file=/egit/updates/org.eclipse.egit.repository-3.3.1.201403241930-r.zip
- install the "Eclipse Git Team Provider" feature
- click Yes to restart

- close Welcome
- Alt+Shift+Q, Q > open Git Repositories view
- add an existing local Git repo
=> Git Repositories view sometimes has most of its toolbar buttons duplicated (similar to bug 402561) 

- select repo, open context menu
=> Context menu is often OK, but sometimes almost empty (see below)

- choose context menu > Show In > History
- click the "Git Repositories" view tab
- open context menu
=> menu is empty except for "Show In" and "Paste Repository Path" items (and sometimes "Compare With"). This is similar to bug 397064.

After a restart, the context menu is usually there again, but it disappears again after a while. Closing and reopening the view also helps sometimes, but it's unclear when (bug 430306).
Comment 1 Markus Keller CLA 2014-04-15 13:28:26 EDT
Nothing in the log.

I've also seen this in I20140408-1645 on GTK with an old version of EGit (2.3.1.201302201838-r), so I doubt it's an EGit issue.
Comment 2 Markus Keller CLA 2014-04-17 05:33:59 EDT
This is a blocker, a regression, and must be fixed for M7.
Comment 3 Wojciech Sudol CLA 2014-04-17 06:01:49 EDT
I'm working on this at the moment.
Comment 4 Markus Keller CLA 2014-04-17 06:47:58 EDT
Thanks Wojciech.
Comment 5 Wojciech Sudol CLA 2014-04-17 07:01:14 EDT
With regards to the duplicated toolbar buttons problem, I can no longer reproduce it (N20140416-2200).
Comment 6 Markus Keller CLA 2014-04-17 08:13:26 EDT
(In reply to Wojciech Sudol from comment #5)
> With regards to the duplicated toolbar buttons problem, I can no longer
> reproduce it (N20140416-2200).

Yup, I also can't reproduce that reliably.

BTW: The missing menus problem also shows up in the History view after a while. I can't compare commits any more or compare an old version with the workspace. Interesting fact: In the Quick Diff menu, I can still reset the baseline to HEAD or HEAD^, but I can't set a specific commit as baseline any more.

Looks like the problem is that the commands don't get the current selection any more or are no longer updated on selection changes.
Comment 7 Wojciech Sudol CLA 2014-04-17 09:28:52 EDT
The problem with empty menu started to occur after the commit 0b8935d41933c2c0237d88e7fc8ab4374a2fb818 with a fix for bug 354538 - "[Contributions] [Compatibility] Window menus and toolbars leaked after having been closed".
General scenario to reproduce the bug:
1. Open Git Repositories view and add an existing repository
2. Close and reopen the view
3. Open context menu on the repository item
The only workaround I found is to restart Eclipse with the Git Repositories view open.
Comment 8 Daniel Rolka CLA 2014-04-17 09:51:17 EDT
(In reply to Wojciech Sudol from comment #7)
> The problem with empty menu started to occur after the commit
> 0b8935d41933c2c0237d88e7fc8ab4374a2fb818 with a fix for bug 354538 -
> "[Contributions] [Compatibility] Window menus and toolbars leaked after
> having been closed".
> General scenario to reproduce the bug:
> 1. Open Git Repositories view and add an existing repository
> 2. Close and reopen the view
> 3. Open context menu on the repository item
> The only workaround I found is to restart Eclipse with the Git Repositories
> view open.

Since we have some workaround for that let me decrease the severity of the bug a bit

Daniel
Comment 9 Wojciech Sudol CLA 2014-04-17 11:05:38 EDT
It seems that the bug 432637 is another effect of this change. I can reproduce the bug only when I run Eclipse with this patch.
Comment 10 Daniel Rolka CLA 2014-04-17 13:04:13 EDT
(In reply to Wojciech Sudol from comment #9)
> It seems that the bug 432637 is another effect of this change. I can
> reproduce the bug only when I run Eclipse with this patch.

I've made the initial investigation and both issues are not caused by the changes introduces in the bug 354538

Basically the context menu disappears when particular view (i.e. Git) either becomes inactive or gets closed.

I will continue investigation of the issue

Daniel
Comment 11 Daniel Rolka CLA 2014-04-17 13:06:49 EDT
*** Bug 432637 has been marked as a duplicate of this bug. ***
Comment 12 Daniel Rolka CLA 2014-04-18 10:05:56 EDT
OK, I've found the cause of the issue with disappearing context menu of the Git view. The regression has been introduced with the Bug 431714 - the changes in the ModelServiceImpl class.

Paul,

Do you want to fix it now or we can just revert the commit and return to it at the beginning of the Mars?

Daniel
Comment 13 Paul Webster CLA 2014-04-22 09:40:36 EDT
(In reply to Daniel Rolka from comment #12)
> OK, I've found the cause of the issue with disappearing context menu of the
> Git view. The regression has been introduced with the Bug 431714 - the
> changes in the ModelServiceImpl class.

What did your investigation reveal?  Were you just checking which commit did it, or did you trace the code?

The commit from bug 431714 is http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=cf7be5c8f93e003afa54c4928cda1d57130ce10f

Maybe in changing some of the conditions we broke part menus:

- if (searchRoot instanceof MPart && (searchFlags & IN_PART) != 0) {
+ if (searchRoot instanceof MPart) {

...

+ if (searchFlags != IN_MAIN_MENU) {
Comment 14 Daniel Rolka CLA 2014-04-22 10:01:33 EDT
(In reply to Paul Webster from comment #13)
> (In reply to Daniel Rolka from comment #12)
> > OK, I've found the cause of the issue with disappearing context menu of the
> > Git view. The regression has been introduced with the Bug 431714 - the
> > changes in the ModelServiceImpl class.
> 
> What did your investigation reveal?  Were you just checking which commit did
> it, or did you trace the code?
> 
> The commit from bug 431714 is
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?id=cf7be5c8f93e003afa54c4928cda1d57130ce10f
> 
> Maybe in changing some of the conditions we broke part menus:
> 
> - if (searchRoot instanceof MPart && (searchFlags & IN_PART) != 0) {
> + if (searchRoot instanceof MPart) {
> 
> ...
> 
> + if (searchFlags != IN_MAIN_MENU) {

I was looking for commits that could break it and I found this one. After reverting it, the context menu works fine. Yes, changes in the condition look suspicious.

I was asking if we are going to fix it or revert the change since we can expect other regressions in other places introduced by the change that we are not aware at this moment,

Daniel
Comment 15 Lars Vogel CLA 2014-04-22 10:09:47 EDT
(In reply to Daniel Rolka from comment #14)
> I was asking if we are going to fix it or revert the change since we can
> expect other regressions in other places introduced by the change that we
> are not aware at this moment,

I would prefer if we fix this issue, instead of reverting the new search API. If we revert, customers need to write this code themself and will have similar issues.
Comment 16 Lars Vogel CLA 2014-04-22 11:53:43 EDT
(In reply to Lars Vogel from comment #15)

Where is the popup menu created? I tried to write a JUnit test for it but if I add the popup menu directly to the application model I get the correct result via the model search service.

It only looks as if the IN_PARTS flag is not directly supported without another flag. Not sure if that is intended, I created Bug 433232 for clarification.
Comment 17 Paul Webster CLA 2014-04-22 12:36:40 EDT
(In reply to Lars Vogel from comment #16)
> (In reply to Lars Vogel from comment #15)
> 
> Where is the popup menu created? I tried to write a JUnit test for it but if
> I add the popup menu directly to the application model I get the correct
> result via the model search service.

Popup menus from the workbench are created in PopupMenuExtender.

What search is being called that then fails?  Do we know that yet?

PW
Comment 18 Paul Webster CLA 2014-04-22 15:18:28 EDT
Adding back the "&& (searchFlags & IN_PART) != 0" on line 271 fixes the problem from comment #7.

Louis-Michel, why was it removed?  Somehow returning the part's menus in this code block is causing them to not be rendered.  I wasn't able to find which findRecursiveElements(*) call was involved, and it is important to know what is going on here.

PW
Comment 19 Louis-Michel Mathurin CLA 2014-04-22 21:40:21 EDT
When you add back the "old" flag test

If you execute the test:
org.eclipse.e4.ui.tests.application.EModelServiceFindTest

in the method:
testFindElementsCombinations

elements = modelService.findElements(application, null,
				EModelService.IN_PART, getSelector("singleValidId"));
assertEquals(0, elements.size());

you will get an assertion fail because it will retrieve a TrimmedWindow.

In this test my expectation is to retrieve 0 element, because there is not element named "singleValidId" in a part (IN_PART)

If my understanding of the model is correct, MWindows can't be in a part, and this is why I added a test for this.

Hope this is clear.

LMM
Comment 20 Louis-Michel Mathurin CLA 2014-04-22 23:37:22 EDT
I added comments on Bug 433232.

The proposed patch will retrieve model elements with the flag IN_PART (when use without another flag)
Comment 21 Paul Webster CLA 2014-04-23 11:14:25 EDT
(In reply to Louis-Michel Mathurin from comment #20)
> I added comments on Bug 433232.

The patch on that bug did not solve the missing menus.  I'm going to have to revert the entire ModelServiceImpl change if this can't be fixed.  M7 wraps up on Friday.

PW
Comment 22 Louis-Michel Mathurin CLA 2014-04-23 11:49:31 EDT
IS there a test that exist to reproduce the bug?
Comment 23 Paul Webster CLA 2014-04-23 12:43:10 EDT
(In reply to Louis-Michel Mathurin from comment #22)
> IS there a test that exist to reproduce the bug?

No, just the steps in comment #7

PW
Comment 24 Louis-Michel Mathurin CLA 2014-04-24 00:10:41 EDT
Created attachment 242264 [details]
The XMI
Comment 25 Louis-Michel Mathurin CLA 2014-04-24 00:16:03 EDT
(In reply to Louis-Michel Mathurin from comment #24)
> Created attachment 242264 [details]
> The XMI

I change the code to make the Git RepositoryView work again by adding the flag again...but I can't identify the reason why traversing MMenu children make the menu disappear !

After running the EModelServiceFindTest.class the only 3 tests that are not passing are the one I added myself.  I ran the same tests with the "old" code and they are failing too.


I included a file in comment number 24, so you can take a look at it and browse the model element and see if you agree with the assertion in the test.

Here are three cases where the findElement is not working as expected(from my perspective) when adding back the flag (searchFlags & IN_PART) != 0"

clazz = MMenuElement.class;
elements = modelService.findElements(application, clazz,
EModelService.IN_ANY_PERSPECTIVE, getSelector(clazz));
assertEquals(4, elements.size());

elements = modelService.findElements(application, clazz,
EModelService.IN_ACTIVE_PERSPECTIVE, getSelector(clazz));
assertEquals(3, elements.size());

elements = modelService.findElements(application, clazz,
EModelService.IN_ANY_PERSPECTIVE | EModelService.IN_MAIN_MENU,
getSelector(clazz));
assertEquals(13, elements.size());
Comment 26 Lars Vogel CLA 2014-04-24 00:36:33 EDT
(In reply to Louis-Michel Mathurin from comment #25)
> (In reply to Louis-Michel Mathurin from comment #24)
> > Created attachment 242264 [details]
> > The XMI
> 
> I change the code to make the Git RepositoryView work again by adding the
> flag again...but I can't identify the reason why traversing MMenu children
> make the menu disappear !
> 
> After running the EModelServiceFindTest.class the only 3 tests that are not
> passing are the one I added myself.  I ran the same tests with the "old"
> code and they are failing too.
> 
> 
> I included a file in comment number 24, so you can take a look at it and
> browse the model element and see if you agree with the assertion in the test.
> 
> Here are three cases where the findElement is not working as expected(from
> my perspective) when adding back the flag (searchFlags & IN_PART) != 0"
> 
> clazz = MMenuElement.class;
> elements = modelService.findElements(application, clazz,
> EModelService.IN_ANY_PERSPECTIVE, getSelector(clazz));
> assertEquals(4, elements.size());
> 
> elements = modelService.findElements(application, clazz,
> EModelService.IN_ACTIVE_PERSPECTIVE, getSelector(clazz));
> assertEquals(3, elements.size());
> 
> elements = modelService.findElements(application, clazz,
> EModelService.IN_ANY_PERSPECTIVE | EModelService.IN_MAIN_MENU,
> getSelector(clazz));
> assertEquals(13, elements.size());

I think the related Gerrit review from Louis https://git.eclipse.org/r/#/c/25456/

With this patch, the Git repository menu works again and the three failing tests are commented out.
Comment 27 Lars Vogel CLA 2014-04-24 01:34:40 EDT
(In reply to Louis-Michel Mathurin from comment #25)

> Here are three cases where the findElement is not working as expected(from
> my perspective) when adding back the flag (searchFlags & IN_PART) != 0"
> 
> clazz = MMenuElement.class;
> elements = modelService.findElements(application, clazz,
> EModelService.IN_ANY_PERSPECTIVE, getSelector(clazz));
> assertEquals(4, elements.size());

If I get the code right, the current logic requires also the IN_PART flag. I think that is to return zero.

> elements = modelService.findElements(application, clazz,
> EModelService.IN_ACTIVE_PERSPECTIVE, getSelector(clazz));
> assertEquals(3, elements.size());

Same here. I think zero is also OK.

> 
> elements = modelService.findElements(application, clazz,
> EModelService.IN_ANY_PERSPECTIVE | EModelService.IN_MAIN_MENU,
> getSelector(clazz));
> assertEquals(13, elements.size());

Same here, to get 13 you have to rewrite the test to the following:

elements = modelService.findElements(application, clazz,
			EModelService.IN_ANY_PERSPECTIVE | 
                        EModelService.IN_MAIN_MENU | 
                        EModelService.IN_PART, getSelector(clazz));
assertEquals(13, elements.size());

This is also in line with the Javadoc of the findMethod <li><b>IN_PART</b> Include MMenu and MToolbar elements owned by parts</;i>.

In summary, I think we should apply the Gerrit review from Louis, it fixes the Git repository issue and the above tests are incorrect.

-----------
Note for myself: Maybe ANYWHERE needs to include IN_PART and IN_MAIN_MENU?
Comment 28 Paul Webster CLA 2014-04-24 14:07:34 EDT
Released latest fix with http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=1993074e222415f655d3782c7f5c051056d7d58c

That appears to have fixed the usecase in comment #7

PW
Comment 29 Dani Megert CLA 2014-04-25 04:54:46 EDT
(In reply to Paul Webster from comment #28)
> Released latest fix with
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?id=1993074e222415f655d3782c7f5c051056d7d58c
> 
> That appears to have fixed the usecase in comment #7
> 
> PW

Yes, it fixed the problem but I'm almost sure this fix is causing IAEs on Mac, see bug 433492.
Comment 30 Dani Megert CLA 2014-04-25 05:32:01 EDT
(In reply to Paul Webster from comment #21)
> (In reply to Louis-Michel Mathurin from comment #20)
> > I added comments on Bug 433232.
> 
> The patch on that bug did not solve the missing menus.  I'm going to have to
> revert the entire ModelServiceImpl change if this can't be fixed.  M7 wraps
> up on Friday.
> 
> PW

This might be the right thing to do at this point, given all the pain it caused (so far).
Comment 31 Paul Webster CLA 2014-04-25 09:27:44 EDT
I've reverted the optimizations from bug 431714 with http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=bb6e9df4cf3e36074fcbd15e4cb1d51fa87232b1

PW
Comment 32 Dani Megert CLA 2014-04-28 05:07:52 EDT
(In reply to Dani Megert from comment #29)
> (In reply to Paul Webster from comment #28)
> > Released latest fix with
> > http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> > ?id=1993074e222415f655d3782c7f5c051056d7d58c
> > 
> > That appears to have fixed the usecase in comment #7
> > 
> > PW
> 
> Yes, it fixed the problem but I'm almost sure this fix is causing IAEs on
> Mac, see bug 433492.

That was not the case.


(In reply to Paul Webster from comment #31)
> I've reverted the optimizations from bug 431714 with
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?id=bb6e9df4cf3e36074fcbd15e4cb1d51fa87232b1
> 
> PW

Shouldn't we reopen bug 431714  then?
Comment 33 Paul Webster CLA 2014-04-28 08:55:43 EDT
(In reply to Dani Megert from comment #32)
> 
> Shouldn't we reopen bug 431714  then?

The basic code to find handlers and commands is still there.  My commits have just removed the optimizations to other areas not related to handlers.

PW
Comment 34 Dani Megert CLA 2014-04-28 09:05:29 EDT
(In reply to Paul Webster from comment #33)
> (In reply to Dani Megert from comment #32)
> > 
> > Shouldn't we reopen bug 431714  then?
> 
> The basic code to find handlers and commands is still there.  My commits
> have just removed the optimizations to other areas not related to handlers.
> 
> PW

Cool, thanks Paul!
Comment 35 Paul Webster CLA 2014-05-01 13:08:41 EDT
In 4.4.0.I20140501-0200

PW