Skip to content

Commit 30f6293

Browse files
EcljpseB0Tiloveeclipse
authored andcommitted
StatusLineManager: don't throw but only log IllegalStateException
beginTask() should be called only once per instance but is still called multiple times. #1107
1 parent 0663bb0 commit 30f6293

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

bundles/org.eclipse.jface/src/org/eclipse/jface/action/StatusLineManager.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import org.eclipse.core.runtime.IProgressMonitor;
1717
import org.eclipse.core.runtime.IStatus;
1818
import org.eclipse.core.runtime.NullProgressMonitor;
19+
import org.eclipse.core.runtime.Status;
20+
import org.eclipse.jface.util.Policy;
1921
import org.eclipse.swt.SWT;
2022
import org.eclipse.swt.graphics.Image;
2123
import org.eclipse.swt.widgets.Composite;
@@ -154,9 +156,13 @@ public IProgressMonitor getProgressMonitor() {
154156
@Override
155157
public void beginTask(String name, int totalWork) {
156158
if (taskStarted != null) {
157-
throw new IllegalStateException(
159+
/// TODO: maybe even logging is too much as long as every SubMonitor.convert()
160+
/// illegally calls beginTask as second time.
161+
Exception e = new IllegalStateException(
158162
"beginTask should only be called once per instance. At least call done() before further invocations", //$NON-NLS-1$
159163
taskStarted);
164+
Policy.getLog().log(Status.warning(e.getLocalizedMessage(), e));
165+
done(); // workaround client error
160166
}
161167
taskStarted = new IllegalStateException(
162168
"beginTask(" + name + ", " + totalWork + ") was called here previously"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -199,9 +205,6 @@ public void setCanceled(boolean value) {
199205

200206
@Override
201207
public void setTaskName(String name) {
202-
if (taskStarted == null) {
203-
throw new IllegalStateException("call to beginTask() missing"); //$NON-NLS-1$
204-
}
205208
progressDelegate.setTaskName(name);
206209

207210
}
@@ -215,7 +218,8 @@ public void subTask(String name) {
215218
@Override
216219
public void worked(int work) {
217220
if (taskStarted == null) {
218-
throw new IllegalStateException("call to beginTask() missing"); //$NON-NLS-1$
221+
Exception e = new IllegalStateException("call to beginTask() missing"); //$NON-NLS-1$
222+
Policy.getLog().log(Status.warning(e.getLocalizedMessage(), e));
219223
}
220224
progressDelegate.worked(work);
221225
}

0 commit comments

Comments
 (0)