Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Lay2014-01-21 09:27:46 +0000
committerMatthias Sohn2014-01-31 14:12:31 +0000
commit08398318ddf2af9a8f3b13158bc8795bf3b77eb7 (patch)
tree48e9574698a06999bb6a83e628c28d66a6a15dd0 /org.eclipse.egit.ui
parent8b3603ac60fe1e9cfdf906ffc11134cd36610b12 (diff)
downloadegit-08398318ddf2af9a8f3b13158bc8795bf3b77eb7.tar.gz
egit-08398318ddf2af9a8f3b13158bc8795bf3b77eb7.tar.xz
egit-08398318ddf2af9a8f3b13158bc8795bf3b77eb7.zip
Fix endless loop of GenerateHistoryJob
The GenerateHistoryJob was scheduled over and over when the following precondiations were met: - The preference "Team > Git > History > Maximum number of commits to show" has to be set to a numer smaller than the number of commits in a repository - The history of the repository is fully loaded into the History view - The user scrolls down to the end or - The user selects a reference which is not yet loaded into the History view Scrolling triggers the event listener added in the constructor of CommitGraphTable (This is done to implement incremental loading). The event listener calls the method loadItem of GitHistory Page to load a given commit specified by its index. This method asks the GenerateHistoryJob if the commit is less than BATCH_SIZE / 2 away from the end, and if so, triggers a new GenerateHistoryJob. After loading the commits the GenerateHistoryJob wrongly computed the value of the incomplete variable. It did not check if all commits of the history were loaded. Because of that the updateUI method did render the UI again leading to another call of the event listener above. This commit adds a check if all commits are loaded. This is unfortunately not easily done with the SWTCommitList. So we check if no new commits were loaded in the current invocation of the GenerateHistoryJob and in that case step out of the loop before the check for incomplete is done. Then the method updateUI in GenerateHistoryJob will not render the UI again and not start the endless loop anymore. But the updateUI method has to render the UI once more after all commits are loaded. This is ensured by the new field forcedRedrawsAfterListIsCompleted. The case that a certain commit should be selected but is not found is handled differently. The UI is not drawn again, but the incomplete warning is updated. Bug: 425691 Change-Id: Ice8c59d537156a52acb80c8e004e838e279cdbe3 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.ui')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GenerateHistoryJob.java41
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java10
2 files changed, 42 insertions, 9 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GenerateHistoryJob.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GenerateHistoryJob.java
index b4f60e77e2..1dbb18bb77 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GenerateHistoryJob.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GenerateHistoryJob.java
@@ -52,6 +52,8 @@ class GenerateHistoryJob extends Job {
private RevFlag highlightFlag;
+ private int forcedRedrawsAfterListIsCompleted = 0;
+
GenerateHistoryJob(final GitHistoryPage ghp, Control control, RevWalk walk,
ResourceManager resources) {
super(NLS.bind(UIText.HistoryPage_refreshJob, Activator.getDefault()
@@ -71,10 +73,14 @@ class GenerateHistoryJob extends Job {
int maxCommits = Activator.getDefault().getPreferenceStore()
.getInt(UIPreferences.HISTORY_MAX_NUM_COMMITS);
boolean incomplete = false;
+ boolean commitNotFound = false;
try {
if (trace)
GitTraceLocation.getTrace().traceEntry(
GitTraceLocation.HISTORYVIEW.getLocation());
+ final boolean loadIncrementally = !Activator.getDefault()
+ .getPreferenceStore()
+ .getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_FINDTOOLBAR);
try {
for (;;) {
int oldsz = loadedCommits.size();
@@ -89,20 +95,30 @@ class GenerateHistoryJob extends Job {
loadedCommits.fillTo(commitToLoad, maxCommits);
commitToShow = commitToLoad;
commitToLoad = null;
- } else
+ boolean commitFound = false;
+ for (RevCommit commit : loadedCommits) {
+ if (commit.getId().equals(commitToShow.getId())) {
+ commitFound = true;
+ break;
+ }
+ }
+ commitNotFound = !commitFound;
+ } else {
loadedCommits.fillTo(oldsz + BATCH_SIZE - 1);
+ if (oldsz == loadedCommits.size()) {
+ forcedRedrawsAfterListIsCompleted++;
+ break;
+ }
+ }
}
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
- final boolean loadIncrementally = !Activator.getDefault().getPreferenceStore()
- .getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_FINDTOOLBAR);
if (loadedCommits.size() > itemToLoad + (BATCH_SIZE / 2) + 1 && loadIncrementally)
break;
- if (maxCommits > 0 && loadedCommits.size() > maxCommits)
+ if (maxCommits > 0 && loadedCommits.size() > maxCommits) {
incomplete = true;
- if (incomplete || oldsz == loadedCommits.size())
break;
-
+ }
if (loadedCommits.size() != 1)
monitor.setTaskName(MessageFormat
.format(UIText.GenerateHistoryJob_taskFoundMultipleCommits,
@@ -118,7 +134,12 @@ class GenerateHistoryJob extends Job {
GitTraceLocation.getTrace().trace(
GitTraceLocation.HISTORYVIEW.getLocation(),
"Loaded " + loadedCommits.size() + " commits"); //$NON-NLS-1$ //$NON-NLS-2$
- updateUI(incomplete);
+ if (commitNotFound) {
+ if (forcedRedrawsAfterListIsCompleted < 1 && !loadIncrementally)
+ page.setWarningTextInUIThread(this);
+ }
+ else
+ updateUI(incomplete);
} finally {
monitor.done();
if (trace)
@@ -133,9 +154,11 @@ class GenerateHistoryJob extends Job {
GitTraceLocation.getTrace().traceEntry(
GitTraceLocation.HISTORYVIEW.getLocation());
try {
- if (!incomplete && loadedCommits.size() == lastUpdateCnt)
+ if (!(forcedRedrawsAfterListIsCompleted == 1) && !incomplete
+ && loadedCommits.size() == lastUpdateCnt)
return;
-
+ if (forcedRedrawsAfterListIsCompleted == 1)
+ forcedRedrawsAfterListIsCompleted++;
final SWTCommit[] asArray = new SWTCommit[loadedCommits.size()];
loadedCommits.toArray(asArray);
page.showCommitList(this, loadedCommits, asArray, commitToShow, incomplete, highlightFlag);
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 13ff85cdd4..d630c320b7 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
@@ -1501,6 +1501,16 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
return this.input;
}
+ void setWarningTextInUIThread(final Job j) {
+ graph.getControl().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (!graph.getControl().isDisposed() && job == j) {
+ setWarningText(UIText.GitHistoryPage_ListIncompleteWarningMessage);
+ }
+ }
+ });
+ }
+
@SuppressWarnings("boxing")
void showCommitList(final Job j, final SWTCommitList list,
final SWTCommit[] asArray, final RevCommit toSelect, final boolean incomplete, final RevFlag highlightFlag) {

Back to the top