Bug 560166 - [Commands][Regression] Handler activation not evaluated
Summary: [Commands][Regression] Handler activation not evaluated
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.15   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.16 M1   Edit
Assignee: Rolf Theunissen CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2020-02-14 16:00 EST by Patrick Tasse CLA
Modified: 2020-04-02 13:54 EDT (History)
4 users (show)

See Also:


Attachments
Snippet plug-in (4.39 KB, application/zip)
2020-02-26 16:26 EST, Patrick Tasse CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Tasse CLA 2020-02-14 16:00:01 EST
We have a command handler that has an And expression with 4 sub-expressions, one of which is a With expression on the activePart (with an InstanceOf expression).

This command is in the main Edit menu (it's actually a handler for the 'org.eclipse.ui.edit.addBookmark' command).

In Eclipse 4.14, the expression is evaluated every time that the Edit menu is shown, when the active part has changed.

In Eclipse 4.15, it is not always evaluated. This causes that the command activation is sometimes inactive when it should be active, and it is sometimes active when it shouldn't, for example when the activePart is null, which leads to runtime exception if the command is invoked in the menu.

Below is the stack trace when the handler activation is evaluated correctly, for both 4.14 and 4.15.

I tried to debug why it doesn't evaluate in 4.15, but it is hard because my workstation freezes completely if there is a breakpoint hit during activation of a menu. I know that it reaches MenuManager.handleAboutToShow(MenuManager.java:469) but it does not reach MenuManagerRenderer.subscribeItemEnabledUpdate(MenuManagerRenderer.java:250).

*** Eclipse 4.14

	at org.eclipse.ui.internal.handlers.HandlerActivation.evaluate(HandlerActivation.java:91)
	at org.eclipse.ui.internal.handlers.LegacyHandlerService$HandlerSelectionFunction.compute(LegacyHandlerService.java:122)
	at org.eclipse.e4.core.internal.contexts.ValueComputation.get(ValueComputation.java:70)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.internalGet(EclipseContext.java:271)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.internalGet(EclipseContext.java:282)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.internalGet(EclipseContext.java:282)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.get(EclipseContext.java:237)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.lookUpHandler(HandlerServiceImpl.java:103)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.setEnabled(HandlerServiceHandler.java:75)
	at org.eclipse.core.commands.Command.setEnabled(Command.java:856)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.canExecute(HandlerServiceImpl.java:179)
	at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRendererFilter.updateElementVisibility(MenuManagerRendererFilter.java:223)
	at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerShowProcessor.showMenu(MenuManagerShowProcessor.java:258)
	at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerShowProcessor.menuAboutToHide(MenuManagerShowProcessor.java:115)
	at org.eclipse.jface.internal.MenuManagerEventHelper.showEventPostHelper(MenuManagerEventHelper.java:95)
	at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.java:469)
	at org.eclipse.jface.action.MenuManager.access$1(MenuManager.java:463)
	at org.eclipse.jface.action.MenuManager$2.menuShown(MenuManager.java:495)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:259)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5676)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1423)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1449)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1428)
	at org.eclipse.swt.widgets.Menu.gtk_show(Menu.java:738)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:2231)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5911)
	at org.eclipse.swt.internal.gtk.GTK._gtk_main_do_event(Native Method)
	at org.eclipse.swt.internal.gtk.GTK.gtk_main_do_event(GTK.java:4168)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1480)
	at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
	at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:1604)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4427)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1160)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1049)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:660)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:559)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:154)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:150)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:657)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:594)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)

*** Eclipse 4.15

	at org.eclipse.ui.internal.handlers.HandlerActivation.evaluate(HandlerActivation.java:91)
	at org.eclipse.ui.internal.handlers.LegacyHandlerService$HandlerSelectionFunction.compute(LegacyHandlerService.java:122)
	at org.eclipse.e4.core.internal.contexts.ValueComputation.get(ValueComputation.java:70)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.internalGet(EclipseContext.java:250)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.get(EclipseContext.java:237)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.lookUpHandler(HandlerServiceImpl.java:103)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.setEnabled(HandlerServiceHandler.java:75)
	at org.eclipse.core.commands.Command.setEnabled(Command.java:856)
	at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:916)
	at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531)
	at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484)
	at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:477)
	at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer.subscribeItemEnabledUpdate(MenuManagerRenderer.java:250)
	at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:236)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:133)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:5797)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:219)
	at org.eclipse.e4.ui.internal.di.UIEventObjectSupplier$UIEventHandler.handleEvent(UIEventObjectSupplier.java:64)
	at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:205)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:203)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
	at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:132)
	at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:75)
	at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:44)
	at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:55)
	at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:63)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
	at org.eclipse.e4.ui.model.application.ui.menu.impl.ItemImpl.setEnabled(ItemImpl.java:332)
	at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRendererFilter.updateElementVisibility(MenuManagerRendererFilter.java:238)
	at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerShowProcessor.showMenu(MenuManagerShowProcessor.java:258)
	at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerShowProcessor.menuAboutToHide(MenuManagerShowProcessor.java:115)
	at org.eclipse.jface.internal.MenuManagerEventHelper.showEventPostHelper(MenuManagerEventHelper.java:95)
	at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.java:469)
	at org.eclipse.jface.action.MenuManager.access$1(MenuManager.java:463)
	at org.eclipse.jface.action.MenuManager$2.menuShown(MenuManager.java:495)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:259)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5687)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1423)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1449)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1428)
	at org.eclipse.swt.widgets.Menu.gtk_show(Menu.java:738)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:2229)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5922)
	at org.eclipse.swt.internal.gtk.GTK.gtk_main_do_event(Native Method)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1486)
	at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(Native Method)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4446)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1160)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1049)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:658)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:557)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:154)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:150)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:657)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:594)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1447)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1420)
Comment 1 Andrey Loskutov CLA 2020-02-14 16:02:43 EST
Patrick, please attach related part from the plugin xml.
Comment 3 Patrick Tasse CLA 2020-02-15 17:48:03 EST
By the way, in the above plugin.xml there are only 3 sub-expressions to the And expression.

When I tested it, I inserted a temporary propertyTester condition as the first sub-expression, that only prints out the above stack trace and returns true. This is how I know that the expression isn't always being evaluated when it should.
Comment 4 Patrick Tasse CLA 2020-02-25 13:13:32 EST
Do you know if this is an issue with how we implemented our command handler extension, or is it a problem in the platform?

Our staging build [1] is consistently failing since we updated the target to use 4.15 (#175), and we can reproduce the problem in our application.

I'm afraid (but I do not know) that this issue could affect other users of the platform.

Let me know if there is anything I can do to help debug.

[1] https://ci.eclipse.org/tracecompass/job/tracecompass-master-nightly-staging/
Comment 5 Andrey Loskutov CLA 2020-02-25 13:22:00 EST
the handler is linked to org.eclipse.ui.edit.addBookmark command.
Who and where contributed this command, to which menu? There were some commits cleaning up menu managers etc, could it be that they cleaned too much? I know that in our product we had also regression in this area with 4.15, but the bug was in our code where an static action instance (! OMG) was continuously re-used in menus. This worked fine before 4.15, because nobody released that contribution. That caused however different kind of problems you have.
Comment 6 Andrey Loskutov CLA 2020-02-25 17:05:33 EST
Patrick, could you please create and attach a simple stripped down plugin demonstratimg the regression? This will simplify bisecting.
Comment 7 Patrick Tasse CLA 2020-02-26 10:53:49 EST
Hi Andrey,

I'm still struggling to create a snippet plug-in that fails, I think because my snippet overrides the handler in a condition where another handler from the application is active. In our real application, no other handler is active when ours should be.

I did notice a big difference between 4.15 and 4.14 though. Our handler activation depends on the activeEditorInput.

In 4.14, the expression is evaluated when you click "Edit" menu and "Add Bookmark..."  menu item is shown. It is then properly enabled or disabled depending on the conditions.

In 4.15, the expression is evaluated when you actually click the "Add Bookmark..." menu item, if it's enabled. Then the handler can be found to be inactive leading, to the exception below (or, in the case of my current snippet plug-in, the action is redirected to the other active handler).

But if the handler is currently inactive, it is impossible to trigger the expression evaluation because the menu item is disabled...

org.eclipse.core.commands.NotHandledException: There is no handler to execute for command org.eclipse.ui.edit.addBookmark
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:501)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:487)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
	at org.eclipse.ui.internal.handlers.LegacyHandlerService.executeCommand(LegacyHandlerService.java:389)
	at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:785)
	at org.eclipse.ui.menus.CommandContributionItem.lambda$3(CommandContributionItem.java:762)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5687)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1423)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4955)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4448)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1160)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1049)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:658)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:557)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:154)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:150)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:657)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:594)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1447)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1420)
Comment 8 Patrick Tasse CLA 2020-02-26 15:11:03 EST
Maybe this will help:

In 4.14, when you click the Edit menu, the bookmark handler is evaluated from this code:

MenuManagerRendererFilter.updateElementVisibility(edit=org.eclipse.e4.ui.model.application.ui.menu.impl.MenuImpl@454f6cc5 (tags: [], contributorURI: null) (widget: Menu {&Undo	Ctrl+Z, &Redo	Shift+Ctrl+Z, |, Cu&t	Ctrl+X, &Copy	Ctrl+C, &Paste	Ctrl+V, |, &Delete	Delete, Select &All	Ctrl+A, |, &Find/Replace...	Ctrl+F, |, Add Bookmar&k..., Add Ta&sk...}, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (label: &Edit, iconURI: null, tooltip: null, mnemonics: null) (enabled: true), org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer@3c8c5513, MenuManager [text=&Edit, id=edit, visible=true], TrimmedWindowImpl (IDEWindow) Context, 2, true)

for (MMenuElement element : menuModel.getChildren()) {
  element:bookmark=org.eclipse.e4.ui.model.application.ui.menu.impl.HandledMenuItemImpl@16117d9 (tags: [], contributorURI: null) (widget: MenuItem {Add Bookmar&k...}, renderer: org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer@3c8c5513, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (label: Add Bookmar&k..., iconURI: null, tooltip: null, enabled: true, selected: false, type: Push) (mnemonics: null) (wbCommand: ParameterizedCommand(Command(org.eclipse.ui.edit.addBookmark,Add Bookmark,
		Add a bookmark,
		Category(org.eclipse.ui.category.edit,Edit,null,true),
		org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@3b5b6df4,
		,,true),null))

But in 4.15, the menu element model is of a different implementation class, DirectMenuItemImpl instead of HandledMenuItemImpl:

MenuManagerRendererFilter.updateElementVisibility(edit=org.eclipse.e4.ui.model.application.ui.menu.impl.MenuImpl@541c76fd (tags: [Opaque], contributorURI: null) (widget: Menu {&Undo	Ctrl+Z, &Redo	Shift+Ctrl+Z, |, Cu&t	Ctrl+X, &Copy	Ctrl+C, &Paste	Ctrl+V, |, &Delete	Delete, Select &All	Ctrl+A, |, &Find/Replace...	Ctrl+F, |, Add Bookmar&k..., Add Ta&sk...}, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (label: &Edit, iconURI: null, tooltip: null, mnemonics: null) (enabled: true), org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer@5f92e5eb, MenuManager [text=&Edit, id=edit, visible=true], TrimmedWindowImpl (IDEWindow) Context, 2, true)

for (MMenuElement element : menuModel.getChildren()) {
  element:bookmark=org.eclipse.e4.ui.model.application.ui.menu.impl.DirectMenuItemImpl@5e7fc012 (tags: [Opaque], contributorURI: null) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (label: null, iconURI: null, tooltip: null, enabled: false, selected: false, type: Push) (mnemonics: null) (contributionURI: null, object: null)

And then it does not evaluate the handler activation due to the check:

element instanceof MHandledMenuItem: false

Which prevents this code from being executed:

((MHandledMenuItem) element).setEnabled(handlerService.canExecute(cmd, staticContext));
Comment 9 Andrey Loskutov CLA 2020-02-26 15:38:50 EST
Patrick, could you say if that was already in M1 or M3 or what is the first build it failed for you?
Comment 10 Andrey Loskutov CLA 2020-02-26 15:55:01 EST
Possible candidates:
 * bug 439783
 * bug 558279
 * bug 508478

Bug 439783 sounds promising.
Comment 11 Andrey Loskutov CLA 2020-02-26 15:57:47 EST
(In reply to Andrey Loskutov from comment #6)
> Patrick, could you please create and attach a simple stripped down plugin
> demonstratimg the regression? This will simplify bisecting.

Please.
Comment 12 Patrick Tasse CLA 2020-02-26 16:26:55 EST
Created attachment 281946 [details]
Snippet plug-in

It's a work in progress but...

1. Open the Edit menu once
2. Create and open two text files
3. Switch between the two text files
4. Open the Edit menu

At that moment, you are supposed to see in console:

*** FooPropertyTester.test() ***

Because that determines whether the FooBookmarkHandler should be active. It should only be active if the text filename contains "foo".

The snippet doesn't show wrong activation of the menu item I think because the default Add Bookmark handler is active as a fall-back for these text files.
Comment 13 Andrey Loskutov CLA 2020-02-26 16:58:48 EST
(In reply to Patrick Tasse from comment #12)
> Created attachment 281946 [details]
> Snippet plug-in
> 
> It's a work in progress but...

But this helps a lot.

With this example we observe that: in 4.14, on *every* "Edit" menu open, handler "activeWhen" condition was evaluated if the active part was changed before.

In 4.15 I see that handler "activeWhen" condition is *sometimes* evaluated on part change, *sometimes* on selection change in Packages Explorer, and very seldom on Edit menu opening.

Patrick, can you please confirm this?

If I revert commit 32c650cf34170478908a1892d64a92aff635b63a (bug 558279) and then commit 6cfae33055b12bd499ac8c2f2588a632d9cea1b8 (bug 439783), I see the old behavior.

Rolf, could you please check this?
Comment 14 Eclipse Genie CLA 2020-02-27 01:57:54 EST
New Gerrit change created: https://git.eclipse.org/r/158458
Comment 15 Rolf Theunissen CLA 2020-02-27 01:58:32 EST
(In reply to Eclipse Genie from comment #14)
> New Gerrit change created: https://git.eclipse.org/r/158458

Opaque menu items need special treatment in MenuManagerRendererFilter. Something like the code in this Gerrit, I have not tested it at all. Will have time tonight to further investigate.
Comment 17 Kalyan Prasad Tatavarthi CLA 2020-04-02 08:29:46 EDT
(In reply to Eclipse Genie from comment #16)
> Gerrit change https://git.eclipse.org/r/158458 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?id=1ebbfb497df26b9bdc3937ee7746268a0ed923f5

Does this commit resolve this bug? If yes, please resolve this bug.