diff --git a/ui/impl/com/intellij/openapi/progress/util/ProgressIndicatorBase.java b/ui/impl/com/intellij/openapi/progress/util/ProgressIndicatorBase.java index 5e062df1947f..0945c4b8785c 100644 --- a/ui/impl/com/intellij/openapi/progress/util/ProgressIndicatorBase.java +++ b/ui/impl/com/intellij/openapi/progress/util/ProgressIndicatorBase.java @@ -47,24 +47,30 @@ public class ProgressIndicatorBase implements ProgressIndicator { enterModality(); } - protected final synchronized void enterModality() { - if (myModalityProgress == this && !myModalityEntered){ - myModalityEntered = true; + protected final void enterModality() { + if (myModalityProgress == this){ if (!EventQueue.isDispatchThread()){ SwingUtilities.invokeLater( new Runnable() { public void run() { - LaterInvocator.enterModal(ProgressIndicatorBase.this); + doEnterModality(); } } ); } else{ - LaterInvocator.enterModal(this); + doEnterModality(); } } } + private void doEnterModality() { + if (!myModalityEntered) { + LaterInvocator.enterModal(this); + myModalityEntered = true; + } + } + public void stop(){ LOG.assertTrue(myRunning, "stop() should be called only if start() called before"); myRunning = false; @@ -72,24 +78,30 @@ public class ProgressIndicatorBase implements ProgressIndicator { exitModality(); } - protected final synchronized void exitModality() { - if (myModalityProgress == this && myModalityEntered){ - myModalityEntered = false; + protected final void exitModality() { + if (myModalityProgress == this){ if (!EventQueue.isDispatchThread()){ SwingUtilities.invokeLater( new Runnable() { public void run() { - LaterInvocator.leaveModal(ProgressIndicatorBase.this); + doExitModality(); } } ); } else{ - LaterInvocator.leaveModal(this); + doExitModality(); } } } + private void doExitModality() { + if (myModalityEntered) { + LaterInvocator.leaveModal(this); + myModalityEntered = false; + } + } + public boolean isRunning() { return myRunning; }