Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Kinzler2010-06-14 06:58:32 +0000
committerMathias Kinzler2010-06-14 06:58:32 +0000
commit335f2091275ee85e88447880cdb5148ca915ee16 (patch)
treeb6d422b0856c4f9e47abc98ccc3e4b82d0aeb727
parent4a71cec90fa8ee0e4b63cc3367247ab5e4f14b48 (diff)
downloadegit-335f2091275ee85e88447880cdb5148ca915ee16.tar.gz
egit-335f2091275ee85e88447880cdb5148ca915ee16.tar.xz
egit-335f2091275ee85e88447880cdb5148ca915ee16.zip
NullPointerException in Git History View
This occurs because these menu actions are implemented using a preference change listener. When the page is disposed, the corresponding actions are not disposed by the history framework, so the registered actions keep listening for the preference changes. To reproduce, open a Git History, then open "History" on some non- Git controlled object in order to dispose the page. Open again a Git History page, then click on the view menu -> Wrap comments (or any other action there). The fix actively disposes the registered actions when the page is disposed. Bug: 316277 Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
index 59f570db0e..6ed15f3fd0 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
@@ -138,6 +138,11 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
private CreatePatchAction createPatchAction = new CreatePatchAction();
+ // we need to keep track of these actions so that we can
+ // dispose them when the page is disposed (the history framework
+ // does not do this for us)
+ private final List<BooleanPrefAction> actionsToDispose = new ArrayList<BooleanPrefAction>();
+
/**
* Determine if the input can be shown in this viewer.
*
@@ -731,6 +736,7 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
}
};
a.apply(a.isChecked());
+ actionsToDispose.add(a);
return a;
}
@@ -742,25 +748,30 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
}
};
a.apply(a.isChecked());
+ actionsToDispose.add(a);
return a;
}
private IAction createShowComment() {
- return new BooleanPrefAction(SHOW_COMMENT,
+ BooleanPrefAction a = new BooleanPrefAction(SHOW_COMMENT,
UIText.ResourceHistory_toggleRevComment) {
void apply(final boolean value) {
layout();
}
};
+ actionsToDispose.add(a);
+ return a;
}
private IAction createShowFiles() {
- return new BooleanPrefAction(SHOW_FILES,
+ BooleanPrefAction a = new BooleanPrefAction(SHOW_FILES,
UIText.ResourceHistory_toggleRevDetail) {
void apply(final boolean value) {
layout();
}
};
+ actionsToDispose.add(a);
+ return a;
}
private void createStandardActions() {
@@ -801,6 +812,10 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
public void dispose() {
Repository.removeAnyRepositoryChangedListener(this);
+ // dispose of the actions (the history framework doesn't do this for us)
+ for (BooleanPrefAction action: actionsToDispose)
+ action.dispose();
+ actionsToDispose.clear();
cancelRefreshJob();
if (popupMgr != null) {
for (final IContributionItem i : popupMgr.getItems()) {
@@ -1106,6 +1121,7 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
}
public void dispose() {
+ // stop listening
prefs.removePropertyChangeListener(this);
}
}

Back to the top