Skip to content
Snippets Groups Projects
Commit 3dbfb0d2 authored by Simon Barner's avatar Simon Barner
Browse files

Fix NPE when deleting components while the Annotation view is visible:

- Ignore update requests for elements that are not hook to a top-level element,
e.g. SET events that are fired when a component is removed (before the actual REMOVE event).
- Otherwise, the AnnotationValueService would create an NPE during the preparation of the context via KernelModelElementUtils.runAsCommand()
refs 1841
parent b209c8e2
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,7 @@ import org.fortiss.tooling.base.ui.annotation.IAnnotationValueService;
import org.fortiss.tooling.base.ui.editpart.DiagramEditPartBase;
import org.fortiss.tooling.base.ui.editpart.ElementEditPartBase;
import org.fortiss.tooling.kernel.model.IProjectRootElement;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.ui.util.SelectionUtils;
import org.fortiss.tooling.kernel.utils.EcoreUtils;
......@@ -71,12 +72,19 @@ public abstract class AnnotationViewPartBase extends ViewPart implements ISelect
private final Adapter changeListener = new AdapterImpl() {
@Override
public void notifyChanged(Notification notification) {
if((notification.getEventType() == Notification.ADD) ||
(notification.getEventType() == Notification.REMOVE || (notification
.getEventType() == Notification.SET))) {
if(notification.getEventType() == Notification.ADD ||
notification.getEventType() == Notification.REMOVE ||
notification.getEventType() == Notification.SET) {
Object notifier = notification.getNotifier();
if(notifier instanceof IModelElement) {
if((notifier instanceof IModelElement) &&
(IPersistencyService.INSTANCE
.getTopLevelElementFor((IModelElement)notifier) != null)) {
// Ignore update requests for elements that are not hook to a top-level element,
// e.g. SET events that are fired when a component is removed (before the actual
// REMOVE event). Otherwise, the AnnotationValueService would create a NPE
// during the preparation of the context via
// KernelModelElementUtils.runAsCommand().
update((IModelElement)notifier);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment