From eea94a4326acf8e8501bc7fe9651a16d64b2e6a7 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 11 Oct 2012 13:47:34 +0400 Subject: [PATCH] optimisation --- .../openapi/progress/impl/ProgressManagerImpl.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java index e83cb1623de2..2ffa08b1f294 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java @@ -219,11 +219,12 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{ } public void executeProcessUnderProgress(@NotNull Runnable process, ProgressIndicator progress) throws ProcessCanceledException { - ProgressIndicator oldIndicator = myThreadIndicator.get(); + ProgressIndicator oldIndicator = null; - if (progress != null) myThreadIndicator.set(progress); + boolean set = progress != null && progress != (oldIndicator = myThreadIndicator.get()); + if (set) myThreadIndicator.set(progress); - final boolean modal = progress != null && progress.isModal(); + boolean modal = progress != null && progress.isModal(); if (modal) myCurrentModalProgressCount.incrementAndGet(); if (progress == null || progress instanceof ProgressWindow) myCurrentUnsafeProgressCount.incrementAndGet(); @@ -231,7 +232,9 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{ process.run(); } finally { - myThreadIndicator.set(oldIndicator); + if (set) { + myThreadIndicator.set(oldIndicator); + } if (modal) myCurrentModalProgressCount.decrementAndGet(); if (progress == null || progress instanceof ProgressWindow) myCurrentUnsafeProgressCount.decrementAndGet();