[Typing freeze logger] do not report on modify-read-only file dialog appcode/163.2392 clion/163.2391
authorYaroslav Lepenkin <yaroslav.lepenkin@jetbrains.com>
Mon, 8 Aug 2016 08:55:01 +0000 (11:55 +0300)
committerYaroslav Lepenkin <yaroslav.lepenkin@jetbrains.com>
Mon, 8 Aug 2016 08:58:38 +0000 (11:58 +0300)
platform/platform-api/src/com/intellij/openapi/editor/actionSystem/FreezeLogger.java

index 5fb426ecb08750ccf9830a7c0bb4c9b6614aa17b..9a520f616df682f66174371b54d9801e82e993ed 100644 (file)
@@ -17,6 +17,7 @@ package com.intellij.openapi.editor.actionSystem;
 
 import com.intellij.diagnostic.ThreadDumper;
 import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.project.Project;
@@ -31,8 +32,9 @@ public class FreezeLogger {
   private static final int MAX_ALLOWED_TIME = 500;
   
   public static void runUnderPerformanceMonitor(@Nullable Project project, @NotNull Runnable action) {
+    final ModalityState initial = ModalityState.current();
     ALARM.cancelAllRequests();
-    ALARM.addRequest(() -> dumpThreads(project), MAX_ALLOWED_TIME);
+    ALARM.addRequest(() -> dumpThreads(project, initial), MAX_ALLOWED_TIME);
     
     try {
       action.run();
@@ -42,7 +44,11 @@ public class FreezeLogger {
     }
   }
   
-  private static void dumpThreads(@Nullable Project project) {
+  private static void dumpThreads(@Nullable Project project, @NotNull ModalityState initialState) {
+    if (!initialState.equals(ModalityState.current())) {
+      return;
+    }
+    
     final String edtTrace = ThreadDumper.dumpEdtStackTrace();
     if (edtTrace.contains("java.lang.ClassLoader.loadClass")) {
       return;