This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 273344 - Deleting text from XML (working copy) or performing a file revert disconnects source from EMF model
Summary: Deleting text from XML (working copy) or performing a file revert disconnects...
Status: VERIFIED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xml (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows Vista
: P2 major (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Chuck Bridgham CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 234191 290929
  Show dependency tree
 
Reported: 2009-04-22 16:58 EDT by Paul Fullbright CLA
Modified: 2010-05-12 11:22 EDT (History)
5 users (show)

See Also:
david_williams: review+


Attachments
patch (2.18 KB, patch)
2010-01-20 18:39 EST, Chuck Bridgham CLA
no flags Details | Diff
Patch to dali code (3.51 KB, patch)
2010-01-21 14:57 EST, Chuck Bridgham CLA
no flags Details | Diff
revert patch (1.64 KB, patch)
2010-01-22 16:51 EST, Chuck Bridgham CLA
no flags Details | Diff
combined wst patch (with addition) (4.24 KB, patch)
2010-01-22 17:11 EST, Paul Fullbright CLA
no flags Details | Diff
patch (858 bytes, patch)
2010-02-15 18:00 EST, Chuck Bridgham CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Fullbright CLA 2009-04-22 16:58:18 EDT
(See bug 234191 for more information)

The distillation of the problem is this:

- We have an EMF resource loaded for the document in the currently open editor.
- User deletes all text (or at least enough text to make document unusable for
current EMF model)
- EMF resource gets unloaded
- EMF2DOM renderer deregisters with xml model.  (At this point it looks like
there is nothing that can be done.  I don't see how the EMF2DOM renderer can be
reassociated with the XML model in the given code without actively calling the
EMF resource to be reloaded.)
- User "undoes" previous action  (note that the file has not been saved as of
yet)
- No reconnection of renderer with XML model occurs, EMF model does not get
reloaded



(from Chuck Bridgham)

Quick glance tells me the EMF2DOM shouldn't unload the EMF Resource quite yet,
but should wait for a save or disposal of the XML model.

The reason the EMF2DOM isn't being notified is it has probably disconnected its
listener from the SSEModel - effectively disposed....

Biggest problem with this theory though is when the user recreates the root
node.... If it doesn't match the EMF Resource, then a new EMF Resource needs to
be reloaded, but if the listener is still active, this could be detected.

In any case this will be a challenging problem for sure.
Comment 1 Neil Hauge CLA 2009-05-13 17:43:49 EDT
For additional clarification, if you break the syntax of the root
node in any way you will run into this problem.  Simply deleting a character of
the element or accidentally removing a '>' could get you into this state.
Comment 2 Carl Anderson CLA 2009-10-08 09:33:10 EDT
Assigning this to Chuck for initial investigation.  I know some work has been done in this area- is it still a problem in WTP 3.2?
Comment 3 Neil Hauge CLA 2009-10-08 13:47:45 EDT
Yes.  This problem still exists in the latest 3.2 code, and is probably one of the worst bugs currently in Dali.  I confirmed this today by testing a file revert after a trivial modification on a valid persistence.xml file.  The result is loss of all model and editing capability related to this root artifact until the workspace is restarted or a project Clean... is performed.
Comment 4 Karen Butzke CLA 2009-12-02 11:34:49 EST
Closing an edited file without saving causes the same issues.  Any progress update for fixing this bug?
Comment 5 David Williams CLA 2009-12-03 10:56:14 EST
Since this blocks a P1 bug, this should be P1 too. We'll need to at least address, if not fix, for M4. 

Thanks,
Comment 6 Chuck Bridgham CLA 2009-12-03 13:21:36 EST
Hi David,  I accept this hotbug, and will mark it as such, but I disagree with marking for M4 the day our milestone shutdown week starts.

I'll plan on addressing this in M5
Comment 7 David Williams CLA 2009-12-03 15:14:00 EST
Ok, thanks Chuck. I was hoping it could at least be investigated in the off chance it was an easy fix. 

Thanks.
Comment 8 Chuck Bridgham CLA 2010-01-19 16:19:10 EST
working on solution.....
Comment 9 Chuck Bridgham CLA 2010-01-20 18:39:40 EST
Created attachment 156743 [details]
patch

Here is a fix, that ensures this only disconnects/unloads the resource on a "REVERT", and ignores all other changes where the header XML has changed.

I tested this, and it works for me...
Comment 10 David Williams CLA 2010-01-21 13:20:48 EST
I've heard this is very very important to get into this week's build to provide adequate testing before M5 .... so, I'm releasing. 

Test well! 

(And feel free to revert if I heard wrong :)
Comment 11 Chuck Bridgham CLA 2010-01-21 14:57:32 EST
Created attachment 156852 [details]
Patch to dali code

I did see in the case of revert, that when the EMF Resource must be unloaded, that the dali model api doesn't react, and "refresh" the model by dumping and recreating a new EMFResource.  this is the pattern that other listeners follow, or at least remove the underlying EMF model, and lazily load when needed.

I'm not claiming this code is very good or correct  (I did get some errors when testing) - but it demonstrates the reaction that is appropriate when such an event is caught.
Comment 12 Chuck Bridgham CLA 2010-01-22 16:50:04 EST
Re-opening because additional api is required to react to "revert" only events

Adding additional patch
Comment 13 Chuck Bridgham CLA 2010-01-22 16:51:09 EST
Created attachment 157002 [details]
revert patch

Adding api on translator resources allowed to call "isReverting()"
Comment 14 Paul Fullbright CLA 2010-01-22 17:11:01 EST
Created attachment 157003 [details]
combined wst patch (with addition)

I think there was one bit of code missing from the latest patch.  There was no isReverting() added to EMF2DOMSSERenderer to return its actual flag, so as a result isReverting() would *always* be false.

I've combined the two above wst patches with this small change and attached that here.
Comment 15 Carl Anderson CLA 2010-01-28 14:05:28 EST
Dropping to P2 and moving to WTP 3.2 M6 - there is a little more to do, but the biggest problem is now fixed.
Comment 16 Paul Fullbright CLA 2010-02-14 00:25:28 EST
Has this not been checked in yet?
Comment 17 Chuck Bridgham CLA 2010-02-15 17:56:24 EST
Checking in wst.common code....

Adding xml.core patch... and transferring to SSE tools to commit rest
Comment 18 Chuck Bridgham CLA 2010-02-15 18:00:54 EST
Created attachment 159133 [details]
patch

Only patch to org.eclipse.wst.xml.core left...
Comment 19 David Williams CLA 2010-02-17 19:06:07 EST
I've released the patch in comment #18 for this week's I-build, so will mark as fixed. Please re-open if I have misunderstood, and there's more to be done.
Comment 20 Paul Fullbright CLA 2010-02-17 19:40:39 EST
Nope, looks good.  Thanks.


I've tested this with our use of the API and it seems to solve most if not all of our problems.  I'll open a different item if something else/related pops up.
Comment 21 Paul Fullbright CLA 2010-05-12 11:22:02 EDT
verified fixed in WTP S-3.2.0M7-20100429210436