Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 321083 - [Commands] Value of persisted RegistryToggleState is null
Summary: [Commands] Value of persisted RegistryToggleState is null
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.7   Edit
Assignee: Platform UI Triaged CLA
QA Contact: Prakash Rangaraj CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-27 21:43 EDT by Eric Jain CLA
Modified: 2010-09-28 23:42 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Jain CLA 2010-07-27 21:43:17 EDT
Build Identifier: 20100617-1415

I have a toggleable command that is defined like so:

      <command
         defaultHandler="..."
            id="toggleTest"
            name="Test">
         <state
               id="org.eclipse.ui.commands.toggleState">
            <class
                  class="org.eclipse.ui.handlers.RegistryToggleState">
               <parameter
                     name="persisted"
                     value="true">
               </parameter>
               <parameter
                     name="default"
                     value="false">
               </parameter>
            </class>
         </state>
      </command>

This works fine, and the state of the command appears (in the UI) to be persisted across application restarts.

However, when I attempt to read the state after restarting, the code fails at the assertion (with an AssertionError, not a NullPointerException) regardless of the prior state:

  Command cmd = ((ICommandService) PlatformUI.getWorkbench()
    .getService(ICommandService.class)).getCommand("toggleTest");
  assert cmd.getState(RegistryToggleState.STATE_ID).getValue() != null;


Reproducible: Always
Comment 1 Prakash Rangaraj CLA 2010-09-28 14:19:12 EDT
Eric, 

   Where are you reading the state? Is it during the workbench startup? Can you attach the stack trace?
Comment 2 Eric Jain CLA 2010-09-28 21:16:42 EDT
The state was being read in a ViewPart.createPartControl. But I'm no longer able to reproduce this issue with Eclipse 3.6.1.
Comment 3 Prakash Rangaraj CLA 2010-09-28 23:42:26 EDT
(In reply to comment #2)
> The state was being read in a ViewPart.createPartControl. But I'm no longer
> able to reproduce this issue with Eclipse 3.6.1.

   Thanks. Closing this bug. If you are able to reproduce again, please attach the stacktrace and reopen the bug