From 7628369f7543f86e896b6b7aaf79cd2e01b2545b Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 29 Jul 2016 19:55:28 +0200 Subject: [PATCH] DumbServiceImpl: cleanup and restore the ability to finish indexing in the same modality state where it was started --- .../com/intellij/openapi/project/DumbServiceImpl.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java index e22c682b0842..38d371ecce15 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java @@ -293,7 +293,7 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica private void queueUpdateFinished(boolean modal) { if (myUpdateFinishedQueued) return; myUpdateFinishedQueued = true; - TransactionGuard.submitTransaction(myProject, () -> ApplicationManager.getApplication().runWriteAction(() -> updateFinished(modal))); + TransactionGuard.getInstance().submitTransaction(myProject, myDumbStartTransaction, () -> WriteAction.run(() -> updateFinished(modal))); } private void updateFinished(boolean modal) { @@ -516,7 +516,7 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica return result.get(); } - private void invokeAndWaitIfNeeded(Runnable runnable) { + private static void invokeAndWaitIfNeeded(Runnable runnable) { Application app = ApplicationManager.getApplication(); if (app.isDispatchThread()) { runnable.run(); @@ -525,14 +525,13 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica Semaphore semaphore = new Semaphore(); semaphore.down(); - //noinspection SSBasedInspection - SwingUtilities.invokeLater(() -> { + app.invokeLater(() -> { try { runnable.run(); } finally { semaphore.up(); } - }); + }, ModalityState.any()); try { semaphore.waitFor(); }