diff options
| author | Maxime Porhel | 2015-08-27 13:38:06 +0000 |
|---|---|---|
| committer | Maxime Porhel | 2015-08-31 09:10:23 +0000 |
| commit | cfc3be679512f85b8a48b9018c93889cdcbb4ead (patch) | |
| tree | 36f1b494e3417a65d057bc61af27259222d33b9d | |
| parent | ecb2b6741e70a927355898d691606a95846278ee (diff) | |
| download | org.eclipse.sirius-cfc3be679512f85b8a48b9018c93889cdcbb4ead.tar.gz org.eclipse.sirius-cfc3be679512f85b8a48b9018c93889cdcbb4ead.tar.xz org.eclipse.sirius-cfc3be679512f85b8a48b9018c93889cdcbb4ead.zip | |
[476203] Avoid NPE occuring during DNodeList font color refresh in undo
This NPE seems to occur only randomly in
KeyboardDeletionFromLabelTests.testDeleteFromLabelWithStandardTool(), I
was also reported by the automatic report but I did not succeed to
reproduce with manual steps.
Remove dead code:
. DNodeListElementEditPart will never have children
parts
. Add isActive() guard before calling refresh(). This should be similar
to a getParent() call. This refresh call seems weird: the refresh() is
already called at the begining of the handleNotificationEvent() method.
Fursthermore, ADD_MANY and REMOVE_MANY cases are forgotten.
The NPE occured because an inactive part receive notification from its
GMF node, but it should have been removed from the DiagramEventBroker
listener during deactivate().
I did not find why this is not the case when the test fails.
Bug:476203
Change-Id: Ic382f114b53bc1b4546a3b8b28f77640debe33dd
Signed-off-by: Maxime Porhel <maxime.porhel@obeo.fr>
Cherry-picked-from: 7e4f1861459da4d9d4f6b194572efa2422c23ce1
3 files changed, 8 insertions, 15 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/DiagramNameEditPartOperation.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/DiagramNameEditPartOperation.java index bba31fcdb3..47ceb1b38f 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/DiagramNameEditPartOperation.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/DiagramNameEditPartOperation.java @@ -114,7 +114,7 @@ public final class DiagramNameEditPartOperation { RGBValues labelRGBColor = lStyle.getLabelColor(); Color labelColor = VisualBindingManager.getDefault().getLabelColorFromRGBValues(labelRGBColor); - if (!figure.getForegroundColor().equals(labelColor)) { + if (!(figure.getForegroundColor() != null && figure.getForegroundColor().equals(labelColor))) { figure.setForegroundColor(labelColor); } if (self instanceof IBorderItemEditPart) { diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramElementEditPartOperation.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramElementEditPartOperation.java index 671f03f398..3612e52443 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramElementEditPartOperation.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramElementEditPartOperation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2014 THALES GLOBAL SERVICES and others. + * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -512,7 +512,7 @@ public final class DiagramElementEditPartOperation { RGBValues labelRGBColor = lStyle.getLabelColor(); Color labelColor = VisualBindingManager.getDefault().getLabelColorFromRGBValues(labelRGBColor); - if (!figure.getForegroundColor().equals(labelColor)) { + if (!(figure.getForegroundColor() != null && figure.getForegroundColor().equals(labelColor))) { figure.setForegroundColor(labelColor); } } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/DNodeListElementEditPart.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/DNodeListElementEditPart.java index 3953c56150..ea3e15f48c 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/DNodeListElementEditPart.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/DNodeListElementEditPart.java @@ -14,11 +14,9 @@ import org.eclipse.draw2d.IFigure; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.EObject; import org.eclipse.gef.DragTracker; -import org.eclipse.gef.EditPart; import org.eclipse.gef.EditPolicy; import org.eclipse.gef.Request; import org.eclipse.gef.requests.SelectionRequest; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx; @@ -172,14 +170,6 @@ public class DNodeListElementEditPart extends AbstractGeneratedDiagramNameEditPa */ @Override protected void handleNotificationEvent(Notification notification) { - final EditPart styleEditPart = getStyleEditPart(); - // Refreshes edit part. - if (styleEditPart != null) { - final EObject element = ((IGraphicalEditPart) styleEditPart).resolveSemanticElement(); - if (element != null && element.eResource() != null) { - styleEditPart.refresh(); - } - } final EObject element = resolveSemanticElement(); if (element != null && element.eResource() != null && getParent() != null) { refresh(); @@ -191,8 +181,11 @@ public class DNodeListElementEditPart extends AbstractGeneratedDiagramNameEditPa } super.handleNotificationEvent(notification); - if (notification.getEventType() == Notification.SET || notification.getEventType() == Notification.UNSET || notification.getEventType() == Notification.ADD) - refresh(); + if (notification.getEventType() == Notification.SET || notification.getEventType() == Notification.UNSET || notification.getEventType() == Notification.ADD) { + if (isActive()) { + refresh(); + } + } } /** |
