Bug 214325 - Bug on the dirty flag of the WorkspaceCommandStack
Summary: Bug on the dirty flag of the WorkspaceCommandStack
Status: VERIFIED FIXED
Alias: None
Product: EMF Services
Classification: Modeling
Component: Transaction (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---   Edit
Assignee: Christian Damus CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-01-04 05:26 EST by Fabrice Dubach CLA
Modified: 2017-02-24 15:10 EST (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 Fabrice Dubach CLA 2008-01-04 05:26:03 EST
Build ID:  I20070625-1500

Steps To Reproduce:
1.Using a transactionnal EMF editor, do several modifications on a document.
2.Save it
3.Undo ALL your modifications. The dirty flag become false at the end of the stack.


More information:
The following method of the WorkspaceCommandStackImpl class :

public boolean isSaveNeeded() {
		IUndoableOperation nextUndoableOperation =
                       history.getUndoOperation(getDefaultUndoContext());
		
		if (nextUndoableOperation == null)
			return false;
		
		return savedContext != null ? 
                  !nextUndoableOperation.hasContext(getSavedContext()) : true;
	}

perhaps should be something like this

public boolean isSaveNeeded() {
		IUndoableOperation nextUndoableOperation = 
                       history.getUndoOperation(getDefaultUndoContext());

		if ( (nextUndoableOperation == null)
                  && (savedContext != null) )
			return false;
		
		return savedContext != null ? 
                  !nextUndoableOperation.hasContext(getSavedContext()) : true;
	}

but we need to test
Comment 1 Christian Damus CLA 2008-01-04 09:29:50 EST
That makes a good deal of sense to me.  The bottom of the command-stack shouldn't be considered as an implicit savepoint unless the editor had never been saved since opening.

That leads me think that the test should actually be:

                if ( (nextUndoableOperation == null)
                  && (savedContext == null) )
                        return false;
Comment 2 Fabrice Dubach CLA 2008-01-04 10:09:10 EST
Christian,
I made obviously a little mistake on my conditional test, 
yours seems to be quite better !
Comment 3 Christian Damus CLA 2008-01-25 09:43:54 EST
Committed the fix to CVS HEAD (1.2 release), with a JUnit test implementing the original problem scenario.

The fix actually ended up slightly different to account for the null 'nextUndoableOperation':

        if (nextUndoableOperation == null) {
            return savedContext != null;
        }
Comment 4 Nick Boldt CLA 2008-01-28 18:23:24 EST
Fix in CVS.
Comment 5 Christian Damus CLA 2008-02-06 21:20:24 EST
Fix available in HEAD: 1.2.0.I200802062040.