diff options
author | Andrey Loskutov | 2015-08-02 15:28:32 +0000 |
---|---|---|
committer | Andrey Loskutov | 2015-08-02 15:28:32 +0000 |
commit | 9e099cb2010fcfb8e27fdf53a6b7b8d367d69a8e (patch) | |
tree | d62775ded9b38bc6a5fb364230f02b66e12f9e71 /org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java | |
parent | 7fc2ef6cf5a5b3bd3364560bbd1347661754e5b5 (diff) | |
download | egit-9e099cb2010fcfb8e27fdf53a6b7b8d367d69a8e.tar.gz egit-9e099cb2010fcfb8e27fdf53a6b7b8d367d69a8e.tar.xz egit-9e099cb2010fcfb8e27fdf53a6b7b8d367d69a8e.zip |
GitHistoryPage jobs should not run in parallel
Diff jobs should not run in parallel to each other and to the
GenerateHistoryJob. Set common scheduling rule and also added proper job
cancellation on dispose() or on diff selection change.
Bug: 473013
Change-Id: I9ec17c1f299e3bd726d9c8620196a92132102417
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java')
-rw-r--r-- | org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java | 55 |
1 files changed, 40 insertions, 15 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 490f35ff8c..a553da0d65 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 @@ -37,6 +37,7 @@ import org.eclipse.core.runtime.jobs.Job; import org.eclipse.egit.core.AdapterUtils; import org.eclipse.egit.core.project.RepositoryMapping; import org.eclipse.egit.ui.Activator; +import org.eclipse.egit.ui.JobFamilies; import org.eclipse.egit.ui.UIPreferences; import org.eclipse.egit.ui.UIUtils; import org.eclipse.egit.ui.internal.CommonUtils; @@ -149,7 +150,7 @@ import org.eclipse.ui.progress.UIJob; /** Graphical commit history viewer. */ public class GitHistoryPage extends HistoryPage implements RefsChangedListener, - ISchedulingRule, TableLoader, IShowInSource, IShowInTargetList { + TableLoader, IShowInSource, IShowInTargetList { private static final int INITIAL_ITEM = -1; @@ -623,6 +624,18 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener, } } + private static class HistoryPageRule implements ISchedulingRule { + @Override + public boolean contains(ISchedulingRule rule) { + return this == rule; + } + + @Override + public boolean isConflicting(ISchedulingRule rule) { + return this == rule; + } + } + private static final String POPUP_ID = "org.eclipse.egit.ui.historyPageContributions"; //$NON-NLS-1$ private static final String DESCRIPTION_PATTERN = "{0} - {1}"; //$NON-NLS-1$ @@ -758,6 +771,8 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener, private volatile boolean resizing; + private final HistoryPageRule pageSchedulingRule; + /** * Determine if the input can be shown in this viewer. * @@ -799,9 +814,11 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener, */ public GitHistoryPage() { trace = GitTraceLocation.HISTORYVIEW.isActive(); - if (trace) + pageSchedulingRule = new HistoryPageRule(); + if (trace) { GitTraceLocation.getTrace().traceEntry( GitTraceLocation.HISTORYVIEW.getLocation()); + } } @Override @@ -1182,6 +1199,11 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener, ((IWorkbenchAction) i).dispose(); } renameTracker.reset(null); + if (job != null) { + job.cancel(); + job = null; + } + Job.getJobManager().cancel(JobFamilies.HISTORY_DIFF); super.dispose(); } @@ -1948,6 +1970,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener, } private void formatDiffs(final List<FileDiff> diffs) { + Job.getJobManager().cancel(JobFamilies.HISTORY_DIFF); if (diffs.isEmpty()) { if (UIUtils.isUsable(diffViewer)) { IDocument document = new Document(); @@ -2006,12 +2029,24 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener, } return Status.OK_STATUS; } + + @Override + public boolean belongsTo(Object family) { + return JobFamilies.HISTORY_DIFF.equals(family); + } }; - uiJob.schedule(); + uiJob.setRule(pageSchedulingRule); + GitHistoryPage.this.schedule(uiJob); return Status.OK_STATUS; } + + @Override + public boolean belongsTo(Object family) { + return JobFamilies.HISTORY_DIFF.equals(family); + } }; - formatJob.schedule(); + formatJob.setRule(pageSchedulingRule); + schedule(formatJob); } private void setWrap(boolean wrap) { @@ -2166,7 +2201,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener, */ private void loadInitialHistory(@NonNull RevWalk walk) { job = new GenerateHistoryJob(this, graph.getControl(), walk, resources); - job.setRule(this); + job.setRule(pageSchedulingRule); job.setLoadHint(INITIAL_ITEM); if (trace) GitTraceLocation.getTrace().trace( @@ -2289,16 +2324,6 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener, } @Override - public boolean contains(ISchedulingRule rule) { - return this == rule; - } - - @Override - public boolean isConflicting(ISchedulingRule rule) { - return this == rule; - } - - @Override public ShowInContext getShowInContext() { if (fileViewer != null && fileViewer.getControl().isFocusControl()) return fileViewer.getShowInContext(); |