aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2011-09-07 04:56:20 (EDT)
committerTomasz Zarna2011-09-07 04:56:20 (EDT)
commitb4e9d54435111303fea0112acfe6d0f6185a0aac (patch)
treeaf3821333cf9ccd5eb0d2d3ef9d1d685cb6d15e9
parent785e22592063936ea7719f287f1573f34b5da91c (diff)
downloadegit-b4e9d54435111303fea0112acfe6d0f6185a0aac.zip
egit-b4e9d54435111303fea0112acfe6d0f6185a0aac.tar.gz
egit-b4e9d54435111303fea0112acfe6d0f6185a0aac.tar.bz2
Potential NPE, the site can be null if the page is shown in a dialogrefs/changes/25/4125/2
According to ISynchronizePageSite.getWorkbenchSite() javadoc, and a real life example from bug 343320, the workbench site can be null. This results in a nasty NPE when the sync is being shown in a dialog. Change-Id: I75c2882aab36016e117b0557ba4e709eb2bc12a2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitActionContributor.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitActionContributor.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitActionContributor.java
index 6385666..a0e20ee 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitActionContributor.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitActionContributor.java
@@ -40,6 +40,7 @@ import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizePageSite;
import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant;
import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup;
+import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.IWorkbenchWindow;
@@ -134,11 +135,11 @@ class GitActionContributor extends SynchronizePageActionGroup {
ISynchronizePageSite site = configuration.getSite();
IWorkbenchSite ws = site.getWorkbenchSite();
- openWorkingFileAction = new OpenWorkingFileAction(ws.getWorkbenchWindow()
- .getActivePage());
-
- site.getSelectionProvider().addSelectionChangedListener(
- openWorkingFileAction);
+ if (ws instanceof IViewSite) {
+ openWorkingFileAction = new OpenWorkingFileAction(ws.getWorkbenchWindow()
+ .getActivePage());
+ site.getSelectionProvider().addSelectionChangedListener(
+ openWorkingFileAction);
+ }
}
-
}