Skip to content

Commit 3455ba6

Browse files
fedejeanneCopilot
andcommitted
Honor 'Always run in background' in IProgressService.run() #4202
Fixes #4202 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c402a17 commit 3455ba6

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/progress/ProgressManager.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,22 +1075,28 @@ public void showInDialog(Shell shell, Job job) {
10751075
@Override
10761076
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable)
10771077
throws InvocationTargetException, InterruptedException {
1078+
if (shouldRunInBackground()) {
1079+
// The "Always run in background" preference must suppress the modal
1080+
// progress dialog for every fork/cancelable combination, not just the
1081+
// backward compatible (fork==false || cancelable==false) path below.
1082+
final ProgressMonitorJobsDialog dialog = new ProgressMonitorJobsDialog(
1083+
ProgressManagerUtil.getDefaultParent());
1084+
dialog.setOpenOnRun(false);
1085+
dialog.run(fork, cancelable, runnable);
1086+
return;
1087+
}
1088+
10781089
if (!fork || !cancelable) {
10791090
// Backward compatible code.
10801091
final ProgressMonitorJobsDialog dialog = new ProgressMonitorJobsDialog(
10811092
ProgressManagerUtil.getDefaultParent());
1082-
if (shouldRunInBackground()) {
1083-
dialog.setOpenOnRun(false);
1093+
Job showDialogJob = scheduleProgressMonitorJob(dialog);
1094+
try {
10841095
dialog.run(fork, cancelable, runnable);
1085-
} else {
1086-
Job showDialogJob = scheduleProgressMonitorJob(dialog);
1087-
try {
1088-
dialog.run(fork, cancelable, runnable);
1089-
} finally {
1090-
// In case the dialog hasn't popped up yet, cancel it so it doesn't pop up after
1091-
// the operation finishes or unwinds with an exception.
1092-
showDialogJob.cancel();
1093-
}
1096+
} finally {
1097+
// In case the dialog hasn't popped up yet, cancel it so it doesn't pop up after
1098+
// the operation finishes or unwinds with an exception.
1099+
showDialogJob.cancel();
10941100
}
10951101
return;
10961102
}

0 commit comments

Comments
 (0)