Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikaël Barbero2013-10-01 12:24:32 -0400
committerMikaël Barbero2013-10-01 12:25:03 -0400
commit2f7f6ea4e6ded38bef85721325f876d3480b7948 (patch)
tree89c262580b471cf99717af107d49c8f8be0fa41b /plugins/org.eclipse.emf.compare.ide.ui/src
parent60fb2da30d947675e43d4d529223530461d37258 (diff)
downloadorg.eclipse.emf.compare-2f7f6ea4e6ded38bef85721325f876d3480b7948.tar.gz
org.eclipse.emf.compare-2f7f6ea4e6ded38bef85721325f876d3480b7948.tar.xz
org.eclipse.emf.compare-2f7f6ea4e6ded38bef85721325f876d3480b7948.zip
Fix potential NPE
Diffstat (limited to 'plugins/org.eclipse.emf.compare.ide.ui/src')
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/CompareInputAdapter.java29
1 files changed, 17 insertions, 12 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/CompareInputAdapter.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/CompareInputAdapter.java
index 78a19aef8..e0d1c2e11 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/CompareInputAdapter.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/CompareInputAdapter.java
@@ -136,7 +136,12 @@ public abstract class CompareInputAdapter extends AdapterImpl implements ICompar
* {@inheritDoc}
*/
public EObject getComparisonObject() {
- return ((TreeNode)getTarget()).getData();
+ // target can be null when getLeft/Right/Ancestor is requested after StructureMergeViewer is disposed.
+ if (getTarget() != null) {
+ return ((TreeNode)getTarget()).getData();
+ } else {
+ return null;
+ }
}
/**
@@ -209,23 +214,23 @@ public abstract class CompareInputAdapter extends AdapterImpl implements ICompar
public ITypedElement getAncestor() {
final ITypedElement ret;
Notifier notifier = getComparisonObject();
- boolean isThreeWay = isThreeWay(notifier);
- if (isThreeWay) {
- IAccessorFactory accessorFactory = getAccessorFactoryForTarget();
- if (accessorFactory != null) {
- org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.legacy.ITypedElement typedElement = accessorFactory
- .createAncestor(getAdapterFactory(), getComparisonObject());
- if (typedElement != null) {
- ret = AccessorAdapter.adapt(typedElement);
+ boolean isThreeWay = isThreeWay(notifier);
+ if (isThreeWay) {
+ IAccessorFactory accessorFactory = getAccessorFactoryForTarget();
+ if (accessorFactory != null) {
+ org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.legacy.ITypedElement typedElement = accessorFactory
+ .createAncestor(getAdapterFactory(), getComparisonObject());
+ if (typedElement != null) {
+ ret = AccessorAdapter.adapt(typedElement);
+ } else {
+ ret = null;
+ }
} else {
ret = null;
}
} else {
ret = null;
}
- } else {
- ret = null;
- }
return ret;
}

Back to the top