| Summary: | Root model elements can't be deleted in local projects | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Modeling] EMFStore | Reporter: | Nikolay Kasyanov <corrmage> | ||||
| Component: | Common | Assignee: | Maximilian Koegel <mkoegel> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | critical | ||||||
| Priority: | P3 | CC: | eclipse, emueller, mkoegel | ||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Nikolay Kasyanov
Yes, removing condition part !(notifier instanceof Project) solved problem, but I don't know if it's safe to do that. Comment pls! Thanks for pinning down this bug! I think the change you suggested is potentially dangerous since receivers might not expect notifications of Project. Maybe they should be aware of that, but for the time being I would suggest the following change. I had no time to test it, I am on the EclipseCon currenly, could you please try? Also it would be great if you could supply a test case. A potential starting point for a test is CompositeOperationTest.abortSmallComposite() in client.test.
Index: src/org/eclipse/emf/emfstore/client/model/impl/StatePersister.java
===================================================================
--- src/org/eclipse/emf/emfstore/client/model/impl/StatePersister.java (revision 12442)
+++ src/org/eclipse/emf/emfstore/client/model/impl/StatePersister.java (working copy)
@@ -5,6 +5,7 @@
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.common.util.BasicEMap;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
@@ -27,7 +28,7 @@
import org.eclipse.emf.emfstore.common.model.util.ModelUtil;
import org.eclipse.emf.emfstore.common.model.util.ProjectChangeObserver;
-public class StatePersister implements CommandObserver, ProjectChangeObserver {
+public class StatePersister extends AdapterImpl implements CommandObserver, ProjectChangeObserver {
private IdEObjectCollection collection;
Index: src/org/eclipse/emf/emfstore/client/model/impl/ProjectSpaceImpl.java
===================================================================
--- src/org/eclipse/emf/emfstore/client/model/impl/ProjectSpaceImpl.java (revision 12442)
+++ src/org/eclipse/emf/emfstore/client/model/impl/ProjectSpaceImpl.java (working copy)
@@ -1682,6 +1682,8 @@
// TODO: initialization order important
this.getProject().addProjectChangeObserver(this.operationRecorder);
this.getProject().addProjectChangeObserver(statePersister);
+ // FIXME: BUGFIX move me into StatePersister
+ this.getProject().eAdapters().add(this.statePersister);
if (project instanceof ProjectImpl) {
((ProjectImpl) this.getProject()).setUndetachable(operationRecorder);
(In reply to comment #1)
> Yes, removing condition part !(notifier instanceof Project) solved problem, but
> I don't know if it's safe to do that.
>
> Comment pls!
Hi! Thanks for quick reply. Tried patch, it doesn't work. I've got your point, but notification doesn't passed to notify method of StatePersister. We found a fix and it seems to work, we will do a code review tomorrow and then check it in. I will let you know. Created attachment 206943 [details]
fixes #362649
The patch attached should solve this bug. As Maximilian pointed out, some receivers do not expect notifications from projects, thus, additionally to removing the check in EObjectChangeNotifier, we added a new filter to the default FilterStack. NotifiableIdEObjectCollectionFilter makes sure that notifications from Projects only come through if that is the desired behavior. Another instanceof-check for project is required in the StatePersisters to prevent it from trying to get an ID from a project and trying to set it in the resource. Otherwise StatePersister will throw a RuntimeException. The proposed patch is OK and has been applied to the master. great news! |