From 9ba7c71133d7c95f19f570e2a2912b32159e9b24 Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Tue, 21 Jul 2026 08:54:47 +0200 Subject: [PATCH] During delete, report progress only on original thread Progress monitors given to the `LocalFile.delete(int, IProgressMonitor)` may require UI access, so reporting work from background thread will break delete operation. To avoid that, report progress on given monitor only if operating on the original thread. Fixes https://github.com/eclipse-platform/eclipse.platform/issues/2819 --- .../filesystem/local/InfiniteProgress.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/InfiniteProgress.java b/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/InfiniteProgress.java index b052c1b1051..61fc86ad152 100644 --- a/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/InfiniteProgress.java +++ b/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/InfiniteProgress.java @@ -21,6 +21,7 @@ * is too costly. The monitor will accept any number of calls to * {@link #worked()}, and will scale the actual reported work appropriately * so that the progress never quite completes. + *

Note, this monitor will only report progress if the thread calling it is the same as the thread that created it.

*/ public class InfiniteProgress { private final int MAX_TICKS = 172; // will be reached after ~ 1 Billion #worked() @@ -28,17 +29,23 @@ public class InfiniteProgress { private int nextTickAfter = 4; private int workReported; private final IProgressMonitor monitor; + private final Thread myThread; protected InfiniteProgress(IProgressMonitor monitor) { this.monitor = monitor; + myThread = Thread.currentThread(); } public void beginTask(String name) { - monitor.beginTask(name, MAX_TICKS); + if (myThread == Thread.currentThread()) { + monitor.beginTask(name, MAX_TICKS); + } } public synchronized void subTask(String name) { - monitor.subTask(name); + if (myThread == Thread.currentThread()) { + monitor.subTask(name); + } } public synchronized void worked() { @@ -49,7 +56,9 @@ public synchronized void worked() { nextTickAfter = 1 + (int) (nextTickAfter * 1.1f); if (workReported < MAX_TICKS) { workReported++; - monitor.worked(1); + if (myThread == Thread.currentThread()) { + monitor.worked(1); + } } } }