Transaction guards
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Tue, 11 Oct 2016 13:43:50 +0000 (15:43 +0200)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Wed, 12 Oct 2016 16:15:34 +0000 (18:15 +0200)
python/src/com/jetbrains/python/console/PydevConsoleRunnerImpl.java
python/src/com/jetbrains/python/console/PythonConsoleToolWindowFactory.kt

index 578323d58e0a9e2310c3c770cb342f0b829ea564..1106b4a6f1dc83906e6de425f72012cc70cc4c8d 100644 (file)
@@ -44,6 +44,7 @@ import com.intellij.internal.statistic.UsageTrigger;
 import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.actionSystem.ex.ActionUtil;
 import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.application.TransactionGuard;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Caret;
@@ -72,6 +73,7 @@ import com.intellij.psi.PsiFile;
 import com.intellij.remote.RemoteProcess;
 import com.intellij.remote.Tunnelable;
 import com.intellij.testFramework.LightVirtualFile;
+import com.intellij.ui.GuiUtils;
 import com.intellij.ui.JBColor;
 import com.intellij.ui.SideBorder;
 import com.intellij.ui.content.Content;
@@ -945,9 +947,7 @@ public class PydevConsoleRunnerImpl implements PydevConsoleRunner {
           myProcessHandler.waitFor();
         }
 
-        UIUtil.invokeLaterIfNeeded(() -> {
-          myRerunAction.consume(myConsoleTitle);
-        });
+        GuiUtils.invokeLaterIfNeeded(() -> myRerunAction.consume(myConsoleTitle), ModalityState.defaultModalityState());
       }
     }.queue();
   }
index 3f22047efdd5d983030d0bd12be3623753517964..5179228976ea1e6f21082df315b8f1c731ea7b24 100644 (file)
@@ -16,6 +16,7 @@
 package com.jetbrains.python.console
 
 import com.intellij.execution.console.LanguageConsoleView
+import com.intellij.openapi.application.TransactionGuard
 import com.intellij.openapi.project.DumbAware
 import com.intellij.openapi.project.Project
 import com.intellij.openapi.wm.ToolWindow
@@ -28,7 +29,7 @@ class PythonConsoleToolWindowFactory : ToolWindowFactory, DumbAware {
 
   override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
     val runner = PythonConsoleRunnerFactory.getInstance().createConsoleRunner(project, null)
-    runner.runSync()
+    TransactionGuard.submitTransaction(project, Runnable { runner.runSync() });
   }
 
   companion object {