From 105a959dde11506ab4b213b7cff54cc047f89db5 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 13 Jan 2012 13:18:20 +0100 Subject: [PATCH] when waitUntilRefreshed is called during refresh running, wait until it finishes --- .../openapi/vcs/changes/UpdateRequestsQueue.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/UpdateRequestsQueue.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/UpdateRequestsQueue.java index 61f3774c8550..b7adf26927d6 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/UpdateRequestsQueue.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/UpdateRequestsQueue.java @@ -52,6 +52,7 @@ public class UpdateRequestsQueue { private volatile boolean myIgnoreBackgroundOperation; private boolean myRequestSubmitted; + private boolean myRequestRunning; private final List myWaitingUpdateCompletionQueue; private final ProjectLevelVcsManager myPlVcsManager; //private final ScheduledSlowlyClosingAlarm mySharedExecutor; @@ -156,7 +157,7 @@ public class UpdateRequestsQueue { semaphore.up(); } }; - if (myRequestSubmitted && !myStopped) { + if (myRequestSubmitted || myRequestRunning) { myWaitingUpdateCompletionQueue.add(runnable); } else { @@ -169,7 +170,7 @@ public class UpdateRequestsQueue { } synchronized (myLock) { - if (!myRequestSubmitted || myStopped) { + if (!myRequestSubmitted && !myRequestRunning) { return; } } @@ -236,9 +237,10 @@ public class UpdateRequestsQueue { private class MyRunnable implements Runnable { public void run() { final List copy = new ArrayList(myWaitingUpdateCompletionQueue.size()); - try { synchronized (myLock) { + LOG.assertTrue(!myRequestRunning); + myRequestRunning = true; if (myStopped) { myRequestSubmitted = false; LOG.debug("MyRunnable: STOPPED, project: " + myProject.getName() + ", runnable: " + hashCode()); @@ -269,6 +271,7 @@ public class UpdateRequestsQueue { LOG.debug("MyRunnable: invokeD, project: " + myProject.getName() + ", runnable: " + hashCode()); } finally { synchronized (myLock) { + myRequestRunning = false; LOG.debug("MyRunnable: delete executed, project: " + myProject.getName() + ", runnable: " + hashCode()); if (! copy.isEmpty()) { myWaitingUpdateCompletionQueue.removeAll(copy);