Bug 109639 - [KeyBindings] keybinding service is deactivated but not reactivated when unregister action
Summary: [KeyBindings] keybinding service is deactivated but not reactivated when unre...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: All All
: P1 major (vote)
Target Milestone: 3.1.1   Edit
Assignee: Douglas Pollock CLA Friend
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-15 13:14 EDT by Amy Wu CLA Friend
Modified: 2005-09-26 16:30 EDT (History)
1 user (show)

See Also:


Attachments
KeyBindingService.patch (1.16 KB, patch)
2005-09-15 13:23 EDT, Amy Wu CLA Friend
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Amy Wu CLA Friend 2005-09-15 13:14:43 EDT
3.1

org.eclipse.ui.internal.KeyBindingService#unregisterAction

If an already unregistered action is unregistered, the keybinding service is 
deactivated but never reactivated.  This is because the keybinding service is 
deactivated when unregistering the action, but if the unregister did not work 
(ie handlerSubmission == null) the keybinding service is never reactivated.

The "if (handlerSubmission != null) {" check should be moved lower.  This is 
what registerAction and setScopes does.

Corrected code:
if ((parent != null) && (parent.activeService == this)) {
    active = true;
    parent.deactivateNestedService();
}

// Remove the current submission, if any.
HandlerSubmission handlerSubmission = (HandlerSubmission) 
handlerSubmissionsByCommandId.remove(commandId);

/*
 * Either activate this service again, or remove the submission
 * myself.
*/
if (parent != null) {
    if (active) {
        parent.activateNestedService(this);
    }
} else {
    if (handlerSubmission != null) {
        Workbench.getInstance().getCommandSupport().removeHandlerSubmission
(handlerSubmission);
        handlerSubmission.getHandler().dispose();
    }
}
Comment 1 Amy Wu CLA Friend 2005-09-15 13:23:56 EDT
Created attachment 27177 [details]
KeyBindingService.patch

patch w/ fix
Comment 2 Douglas Pollock CLA Friend 2005-09-21 14:56:57 EDT
I wish all bugs filed were like this.  I'll try to make sure that this makes 
it into 3.2 M3. 
 
Comment 3 Amy Wu CLA Friend 2005-09-21 16:33:21 EDT
Changing to critical because every time you register a new action while a 
keybinding is active, the keybinding will always be deactivated.

The following happens:
1. registerAction (newAction)
2. registerAction always calls unregisterAction(newAction)
3. unregisterAction deactivates current keybinding
4. unregisterAction tries to unregister newAction but since it's new, you end 
up with handlersubmission == null
5. keybinding is never reactivated because handlersubmission == null

The result for the end user is they cannot use shortcut keys until the 
keybinding is reactivated another way (usually by clicking another part, then 
clicking back)  This could be confusing to the user, who may think they lost 
function.

This bug was discovered in the WTP multipage XML editor, and since the
December release of WTP is currently planning on using the 3.1.1 base, we'd 
really like this bug to be fixed in 3.1.1.

Thanks.
Comment 4 Douglas Pollock CLA Friend 2005-09-21 17:23:47 EDT
"critical" means "crashes, loss of data, severe memory  
leak" (https://bugs.eclipse.org/bugs/page.cgi?id=fields.html#bug_severity).  
 
  
Comment 5 David Williams CLA Friend 2005-09-21 17:45:54 EDT
Thanks Doug, just wanted to admit the "critical" setting was my fault in 
giving bad advice to Amy. 

I should remember not to rely on my memory. 

"loss of function" is what we were after. 

thanks again. 
Comment 6 Douglas Pollock CLA Friend 2005-09-21 18:56:31 EDT
Fixed on the R3_1_maintenance stream.  It will have to wait until 3.2 M2 is 
declared before it can be released to HEAD. 
Comment 7 Douglas Pollock CLA Friend 2005-09-26 13:34:49 EDT
Fix released to HEAD. 
Comment 8 Douglas Pollock CLA Friend 2005-09-26 13:55:38 EDT
Amy: Does this work as expected in 3.1.1 RC2 and 3.2 M2?  
  
Comment 9 Douglas Pollock CLA Friend 2005-09-26 13:56:43 EDT
(as a note, 3.1.1 RC2 is M20050923-1430) 
Comment 10 Amy Wu CLA Friend 2005-09-26 16:14:08 EDT
Just tried 3.1.1 RC2 (M20050923-1430) and it did indeed fix my problem.

Thanks!
Comment 11 Douglas Pollock CLA Friend 2005-09-26 16:30:12 EDT
Marking as verified.