Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 175828

Summary: Missing canUndo check in Compound Commands undo implementation
Product: [Tools] GEF Reporter: Suresh Mathew <suresh.mathew>
Component: GEF-Legacy GEF (MVC)Assignee: gef-inbox <gef-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: nyssen, suresh.mathew
Version: 3.2.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Suresh Mathew CLA 2007-02-28 08:41:24 EST
In org.eclipse.gef.commands.CompoundCommand class,
the undo function should check for each command's canUndo() before calling the undo. In normal cases the existing implementation works will be okay but in some cases the client might really want not to undo depending on the conditions they might have implemented in their canUndo(). Does that make sense?
Comment 1 Alexander Nyßen CLA 2010-04-14 17:05:22 EDT
The Javadoc of Command.undo() states the following:

/**
 * Undoes the changes performed during <code>execute()</code>. This method should only be
 * called after <code>execute</code> has been called, and only when <code>canUndo()</code>
 * returns <code>true</code>.
 * @see #canUndo()
 */

According to this, CompoundCommand.undo() does not have to check canUndo(). Instead, a client would have to call canUndo() (which is implemented correctly, as it evaluates the canUndo() results of all its composed commands) before calling undo() on the compound command.