From 1072cf8297d0690cafa0b26c48d2bd09247be048 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 2 Jul 2013 15:56:39 +0200 Subject: [PATCH] IDEA-109872 (supplant long running on-frame-activation refresh sessions) --- .../com/intellij/ide/SaveAndSyncHandlerImpl.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/SaveAndSyncHandlerImpl.java b/platform/platform-impl/src/com/intellij/ide/SaveAndSyncHandlerImpl.java index 80a6b1ac8d67..1cec7a4e16bf 100644 --- a/platform/platform-impl/src/com/intellij/ide/SaveAndSyncHandlerImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/SaveAndSyncHandlerImpl.java @@ -32,6 +32,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.newvfs.ManagingFS; import com.intellij.openapi.vfs.newvfs.NewVirtualFile; import com.intellij.openapi.vfs.newvfs.RefreshQueue; +import com.intellij.openapi.vfs.newvfs.RefreshSession; import com.intellij.util.Alarm; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; @@ -56,6 +57,8 @@ public class SaveAndSyncHandlerImpl implements ApplicationComponent, SaveAndSync private final AtomicInteger myBlockSyncOnFrameActivationCount = new AtomicInteger(); private final Alarm myRefreshDelayAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD); + private long myRefreshSessionId = 0; + public static SaveAndSyncHandlerImpl getInstance(){ return (SaveAndSyncHandlerImpl) ApplicationManager.getApplication().getComponent(SaveAndSyncHandler.class); } @@ -168,7 +171,6 @@ public class SaveAndSyncHandlerImpl implements ApplicationComponent, SaveAndSync if (canSyncOrSave()) { refreshOpenFiles(); } - maybeRefresh(ModalityState.NON_MODAL); } }, 300, ModalityState.NON_MODAL); @@ -178,7 +180,15 @@ public class SaveAndSyncHandlerImpl implements ApplicationComponent, SaveAndSync public void maybeRefresh(@NotNull ModalityState modalityState) { if (myBlockSyncOnFrameActivationCount.get() == 0) { LOG.debug("VFS refresh started"); - RefreshQueue.getInstance().refresh(true, true, null, modalityState, ManagingFS.getInstance().getLocalRoots()); + + RefreshQueue queue = RefreshQueue.getInstance(); + queue.cancelSession(myRefreshSessionId); + + RefreshSession session = queue.createSession(true, true, null, modalityState); + session.addAllFiles(ManagingFS.getInstance().getLocalRoots()); + myRefreshSessionId = session.getId(); + session.launch(); + LOG.debug("VFS refresh finished"); } }