Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Charles David2018-10-11 09:46:04 +0000
committerPierre-Charles David2018-10-11 12:04:55 +0000
commit192174084189f754c76328383d4e08dfcb1e4ea8 (patch)
tree44df29e660e7fbf9f14508bc71c6c5f277c7b8e5
parent0b61c7801bdd20378e2b767385e3f8e4d73c9248 (diff)
downloadorg.eclipse.sirius-192174084189f754c76328383d4e08dfcb1e4ea8.tar.gz
org.eclipse.sirius-192174084189f754c76328383d4e08dfcb1e4ea8.tar.xz
org.eclipse.sirius-192174084189f754c76328383d4e08dfcb1e4ea8.zip
[527109] Fix potential NPE in StandardModeAction
The StandardModeAction fields can become null at the "wrong" time if dispose() is called from another thread, either in the middle of a method or between calls to methods that check for nullness and others that use without checking. Bug: 527109 Change-Id: Ia45a0fac5b7b866c3680d1745c2acb6702e77f81 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/contributions/StandardModeAction.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/contributions/StandardModeAction.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/contributions/StandardModeAction.java
index cb4fef98ab..e508018635 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/contributions/StandardModeAction.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/contributions/StandardModeAction.java
@@ -93,18 +93,23 @@ public class StandardModeAction extends CheckedPropertyAction {
}
@Override
- protected boolean calculateChecked() {
+ protected synchronized boolean calculateChecked() {
return ddiagram != null && !ddiagram.isIsInShowingMode() && !ddiagram.isIsInLayoutingMode();
}
@Override
- protected void doRun(IProgressMonitor progressMonitor) {
+ protected synchronized void doRun(IProgressMonitor progressMonitor) {
+ if (editor == null || ddiagram == null) {
+ // Can happen if we've been disposed since calculateChecked/calculateEnabled has been called.
+ return;
+ }
TransactionalEditingDomain editingDomain = (TransactionalEditingDomain) editor.getEditingDomain();
if (editingDomain != null) {
// We don't use a command stack because we don't want the mode update to be undone
TransactionImpl t = new TransactionImpl(editingDomain, false, Collections.EMPTY_MAP);
try {
+
t.start();
this.ddiagram.setIsInLayoutingMode(false);
this.ddiagram.setIsInShowingMode(false);
@@ -119,7 +124,7 @@ public class StandardModeAction extends CheckedPropertyAction {
}
@Override
- protected boolean calculateEnabled() {
+ protected synchronized boolean calculateEnabled() {
return ddiagram != null && editor != null;
}
@@ -182,7 +187,7 @@ public class StandardModeAction extends CheckedPropertyAction {
* @see org.eclipse.gmf.runtime.diagram.ui.actions.DiagramAction#dispose()
*/
@Override
- public void dispose() {
+ public synchronized void dispose() {
ddiagram = null;
modesMenuManager = null;
editor = null;

Back to the top