This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
- Create Web Application - Make any modification in web.xml - Close te Web Application (Close Project) - In Save dialog click button Discard All. The Web Application is closed - Re-open the Web Application (Open Recent Project) - The web.xml is still changed but SaveCookie is not set. Consequent chchanges of web.xml have no influence to on SaveCookie, so it is impossible to save changes
Works fine for any file in J2SE project. A memory leak in web?
The problem is that DataObject does not know that modified data has been discarded. Method theEnd() in ExitDialog calls setModified(false) on each DataObject belonging to closing projects but nothing else. It is fine for saved data objects but modified data objects are marked as unmodified without reloading the original data. I think there should be called setValid(false) for each data object. Following change seems to be helpful: RCS file: /cvs/projects/projectui/src/org/netbeans/modules/project/ui/ProjectUtilities.java,v retrieving revision 1.18 diff -u -r1.18 ProjectUtilities.java --- org/netbeans/modules/project/ui/ProjectUtilities.java 5 Apr 2005 07:53:57 -0000 1.18 +++ org/netbeans/modules/project/ui/ProjectUtilities.java 7 Apr 2005 13:36:33 -0000 @@ -28,6 +28,7 @@ import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; +import java.beans.PropertyVetoException; import javax.swing.Action; import javax.swing.JFrame; import javax.swing.SwingUtilities; @@ -122,9 +123,13 @@ if (!openFiles.isEmpty () && ExitDialog.showDialog (openFiles)) { // close documents - Iterator it = tc2close.iterator (); - while (it.hasNext ()) { - ((TopComponent)it.next ()).close (); + for (Iterator it = openFiles.iterator(); it.hasNext();) { + DataObject dataObject = (DataObject) it.next(); + try { + dataObject.setValid(false); + } catch (PropertyVetoException e) { + ErrorManager.getDefault().notify(e); + } } } else { // signal that close was vetoed
Careful here. Get a second opinion from someone who understands how data object modification works. Petr N. maybe?
There was a bug 57483 depending on this that is not fixed. So no action is needed. Now there is another bug 57626. Please tell us exactly what is wrong and why it should be fixed in projects and make sure that XmlMultiview support works correctly before doing this. Re setValid(): I disagree. It is not a right way how to fix your problem.
It is not clear what is wrong from the report.
There was lot of stuff in issue 47483 so I split it into 57483 and 57626. Now only the issue 57626 depends on this. I'll try to describe the problem : In xml/multiview editor we modify the data model (schema2beans model) related to xml document (web.xml). Normally when editor is closed and changes are discarded we refresh the data model back from file. This is because the core/multiview + core/windows infrastructure informs us that changes were discarded. On other hand : if the project is closed with web.xml open(Close->Discard All) only the DataObject.setModified(false) is called. Here we don't have the possibility to do a "cleanup" (e.g. to refresh model back from file). Another problem is that after reopening the project (the editor top components are deserialized that time) the text is changed in editor and Save button disabled forever. Do we do something wrong?
Re setValid(): From my point of view setValid(false) works fine, but I am not expert in this area. It does not matter how we would be notified that project was closed or changes were discarded. Just suggest any other suitable solution.
The problem appears only with web.xml file not for others. Is it possible to handle this on web.xml side? What about listen on setModified(false) and do necessary 'cleanup' on this? Other file types can get over it and don't ask any special handling. Isn't this patch an overkill for others files?
The solution in dd editors would be a workaround, not solution. The problem is reproducible also in J2SE. Scenario: - Create Java Application - Modify Main.java - Clone document Main.java - Move cloned Main.java using drag&drop to another part of workspace (for example to the right). - Close the Java Application and choose Discard All in Save dialog. Main.java remains modified but save button is disabled. Fortunately the cloned Main.java is not closed owing to problem described in Issue 57621, so the bug is reproducible also in J2SE even though there exists a workaround partially solving the issue.
Listening on setModified(false) don't help us much as setModified(false) is also called in these cases : - Data Object is saved - Data Object is closed with Save Option - Data Object is saved with Discard option We probably need something more. I think, we can live with 57626 for release41 (its quite a corner case when project is closed, changes are discarded for data object and project is opened again).
re pfiala's last comment: this is another problem - during project close only documents edited in components that reside in editor mode are searched. Please file it as separate bug so we do not mix the problems here.
The reason of your problem is that notifyUnmodified() is not called on your editor when the project is closed and closes all components belonging to project. This works well for default DOs, Java sources or JSPs. Please reevaluate to find if it is related to multiview or your implementation of XML editing support.
I think notifyUnmodified() just notifies that data in EditorSupport has been synchronized with data in persistent storage and no additional action is required to synchronize data. Do you think I am not right?
The same problem has sun-web.xml that has nothing common with core/multiview or xml/multiview. What should be done to get notifyUnmodified() called?
I am sorry. I didn't want to change the component and subcomponent.
Right, it is not exactly notifyUnmodified(). It is rather bad closing of component. How it works for other files during project close - DOs that are edited are gathered and user is asked to save them - if she decides not to save them these DOs are marked as unmodified using DO.setModified(false), the editor support is not altered yet - all documents maintained by editor supports are closed and this results in call to notifyUnmodified() where save cookie is often removed. You can look into form how it works there. I really don't know anything about sun-web.xml
I don't understand how can DO determine whether the changes were saved or discarded if in both cases the same action is performed (setModified(false)).
If I see result of scenario above that reproduces the issue in J2SE, the data in DO are out of sync until the project is reopen and it is incorrect behavior. When we close project with discarding changes we need to notify DO that the modified data is invalid. I am confident it is the only right flow.
The problem in J2SE will be fixed together with issue 57621. The problem stays valid only for web.xml, IMHO still fixable in xml/multiview editing support.
Fixes of Issue 57626 and Issue 57621 have eliminated impact of this issue, so the priority is not so high. Despite there are no known visible consequences of this issue I consider the solution of this issue pretty important. We need to notify data object or editor support about discarding changes. I think we must not rely on reset data after closing the last editor.
Do we need a new API permitting code to programmatically close a window and save or discard changes? I think this may be the first time it is required, since the exit dialog doesn't have to worry about what happens after the VM exits.
Reassign to new owner.
*** Issue 84236 has been marked as a duplicate of this issue. ***
The issue has been partially fixed and from subsequent comments it looks like it's not clear what the problem really is. Closing as wontfix.