From 93e7c66a890f8cfb4aec6941c94e0fe6f27a13af Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 20 Jul 2012 17:16:42 +0200 Subject: [PATCH] fix race condition: IDEA-88912 Ant completion message not always displayed --- .../config/execution/AntBuildMessageView.java | 19 +++++++++---------- .../config/execution/ExecutionHandler.java | 8 +++++--- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/plugins/ant/src/com/intellij/lang/ant/config/execution/AntBuildMessageView.java b/plugins/ant/src/com/intellij/lang/ant/config/execution/AntBuildMessageView.java index e517dea7cc15..59c9d0b8fb58 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/execution/AntBuildMessageView.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/execution/AntBuildMessageView.java @@ -781,10 +781,7 @@ public final class AntBuildMessageView extends JPanel implements DataProvider, O return myWarningCount; } - void buildFinished(boolean isProgressAborted, - long buildTimeInMilliseconds, - @NotNull final AntBuildListener antBuildListener, - OutputPacketProcessor dispatcher) { + void buildFinished(boolean isProgressAborted, long buildTimeInMilliseconds, @NotNull final AntBuildListener antBuildListener, OutputPacketProcessor dispatcher) { final boolean aborted = isProgressAborted || myIsAborted; final String message = getFinishStatusText(aborted, buildTimeInMilliseconds); @@ -800,12 +797,12 @@ public final class AntBuildMessageView extends JPanel implements DataProvider, O } } }); - if (!myIsOutputPaused) { - new OutputFlusher().doFlush(); - myTreeView.scrollToLastMessage(); - } - ApplicationManager.getApplication().invokeLater(new Runnable() { + //noinspection SSBasedInspection + SwingUtilities.invokeLater(new Runnable() { public void run() { + if (!myIsOutputPaused) { + new OutputFlusher().doFlush(); + } final AntBuildFileBase buildFile = myBuildFile; if (buildFile != null) { if (getErrorCount() == 0 && buildFile.isViewClosedWhenNoErrors()) { @@ -818,7 +815,9 @@ public final class AntBuildMessageView extends JPanel implements DataProvider, O myTreeView.scrollToStatus(); } } - + else { + myTreeView.scrollToLastMessage(); + } VirtualFileManager.getInstance().refresh(true, new Runnable() { public void run() { antBuildListener.buildFinished(aborted ? AntBuildListener.ABORTED : AntBuildListener.FINISHED_SUCCESSFULLY, getErrorCount()); diff --git a/plugins/ant/src/com/intellij/lang/ant/config/execution/ExecutionHandler.java b/plugins/ant/src/com/intellij/lang/ant/config/execution/ExecutionHandler.java index 74beb9b8bf23..77e160881c88 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/execution/ExecutionHandler.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/execution/ExecutionHandler.java @@ -176,15 +176,17 @@ public final class ExecutionHandler { final long buildTime = System.currentTimeMillis() - startTime; checkCancelTask.cancel(); parser.setStopped(true); + final OutputPacketProcessor dispatcher = handler.getErr().getEventsDispatcher(); + errorView.buildFinished(progress != null && progress.isCanceled(), buildTime, antBuildListener, dispatcher); ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { - if (project.isDisposed()) return; + if (project.isDisposed()) { + return; + } errorView.removeProgressPanel(); ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW); if (toolWindow != null) { // can be null if project is closed toolWindow.activate(null, false); - final OutputPacketProcessor dispatcher = handler.getErr().getEventsDispatcher(); - errorView.buildFinished(progress != null && progress.isCanceled(), buildTime, antBuildListener, dispatcher); } } }, ModalityState.NON_MODAL);