diff options
author | Kevin Sawicki | 2012-06-01 00:39:24 +0000 |
---|---|---|
committer | Matthias Sohn | 2012-06-04 14:48:50 +0000 |
commit | d3a6b1e63166b1a7036c2f268ed5644183ec9959 (patch) | |
tree | e4ddc46ff0789cd7bd7a8eb52c1604a33919c243 | |
parent | bc785070f9bd4f3e991c05fbdc2963c819e17238 (diff) | |
download | egit-d3a6b1e63166b1a7036c2f268ed5644183ec9959.tar.gz egit-d3a6b1e63166b1a7036c2f268ed5644183ec9959.tar.xz egit-d3a6b1e63166b1a7036c2f268ed5644183ec9959.zip |
[historyView] Perform clear on background thread when disposed
An NPE can occur if SWTCommitList.clear() is called
from dispose() while fillTo() is running from
GenerateHistoryJob.
dispose() is always called on the UI-thread so schedule
a background thread that synchronizes on the instance
and calls clear since all other state accessing calls to
the SWTCommitList instance are done inside synchronized
blocks.
Change-Id: I855d5bfeb5131c634b4790e6b7231424f2be4566
-rw-r--r-- | org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTCommitList.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTCommitList.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTCommitList.java index 6a84ea5598..36603dd530 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTCommitList.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTCommitList.java @@ -11,6 +11,10 @@ package org.eclipse.egit.ui.internal.history; import java.util.ArrayList; import java.util.LinkedList; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jgit.revplot.PlotCommitList; import org.eclipse.jgit.revplot.PlotLane; import org.eclipse.swt.events.DisposeEvent; @@ -53,7 +57,19 @@ class SWTCommitList extends PlotCommitList<SWTCommitList.SWTLane> implements Dis } public void dispose() { - clear(); + Job clearJob = new Job("Clearing commit list") { //$NON-NLS-1$ + + @Override + protected IStatus run(IProgressMonitor monitor) { + synchronized (SWTCommitList.this) { + clear(); + } + return Status.OK_STATUS; + } + }; + clearJob.setSystem(true); + clearJob.schedule(); + for (Color color : allColors) color.dispose(); if (!control.isDisposed()) |