Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334163 - PluginAction allows disabled actions to run
Summary: PluginAction allows disabled actions to run
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-12 15:36 EST by Brian Bauman CLA
Modified: 2011-01-13 07:52 EST (History)
4 users (show)

See Also:


Attachments
Proposed patch based on Eclipse 3.4.2 (1.21 KB, patch)
2011-01-12 15:55 EST, Brian Bauman CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Bauman CLA 2011-01-12 15:36:25 EST
Build Identifier: 3.4.2

The logic in PluginAction.runWithEvent only checks for enablement the first time an action is run.  The first time through the delegate is created which is followed by checking to see if the action is enabled.  If the action is disabled then the execution returns.  If the user tries to run the action again (allowed in a code path in our product), then the enablement is never checked and the action is executed.

The solution is very simple.  Move the isEnabled check outside the "if (delegate == null)" check.  This would provide the same behavior on the first pass, but correctly handle the case if an action is trying to be rerun that is disabled.

I am attaching a patch with the proposed fix

Reproducible: Always

Steps to Reproduce:
Reproducible in IBM/Lotus product.  I have not been able to reproduce in vanilla Eclipse.
Comment 1 Brian Bauman CLA 2011-01-12 15:55:08 EST
Created attachment 186677 [details]
Proposed patch based on Eclipse 3.4.2
Comment 2 Brian Bauman CLA 2011-01-12 15:58:59 EST
If possible, I would really appreciate if this could be considered for Eclipse
3.7.
Comment 3 Paul Webster CLA 2011-01-13 07:43:26 EST
It's the responsibility of the caller to check enabled state before calling.

ActionContributionItems disable the menus and tool items based on that state, so that it cannot be called.  The key binding system checks isEnabled before calling (which runs through the command system), and programmatic executing through the IHandlerService (which goes through Command) also calls isEnabled() before executing (both delegate to the action).

PW
Comment 4 Paul Webster CLA 2011-01-13 07:52:35 EST
I'll also say I do like that your request came with a patch.

Still, I don't want to change an execution path in the heart of the legacy action delegate support.

PW