From fc9ea9bc2003a69324b4ea6ab56d94b4f693e1c5 Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Fri, 24 Jun 2016 20:29:00 +0300 Subject: [PATCH] PY-19920 Do not update cache of packages on EDT in PyActiveSdkModuleConfigurable#apply() I explicitly call VFSTestFrameworkListener#isTestFrameworkInstalled() in pooled thread skipping the MergingUpdateQueue since (rather confusingly) it executes scheduled updates in the current thread when one calls MergingUpdateQueue#flush() even when it was explicitly stated that its alarm should use thread pool. --- .../PyActiveSdkModuleConfigurable.java | 6 ++++-- .../testing/VFSTestFrameworkListener.java | 18 +++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/python/python-community-configure/src/com/jetbrains/python/configuration/PyActiveSdkModuleConfigurable.java b/python/python-community-configure/src/com/jetbrains/python/configuration/PyActiveSdkModuleConfigurable.java index cb2d258fd97d..f32655c932ca 100644 --- a/python/python-community-configure/src/com/jetbrains/python/configuration/PyActiveSdkModuleConfigurable.java +++ b/python/python-community-configure/src/com/jetbrains/python/configuration/PyActiveSdkModuleConfigurable.java @@ -16,6 +16,7 @@ package com.jetbrains.python.configuration; import com.intellij.application.options.ModuleAwareProjectConfigurable; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.options.ConfigurationException; @@ -53,10 +54,11 @@ public class PyActiveSdkModuleConfigurable extends ModuleAwareProjectConfigurabl for (Module module : ModuleManager.getInstance(myProject).getModules()) { final Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); if (sdk != null) { - VFSTestFrameworkListener.getInstance().updateAllTestFrameworks(sdk); + ApplicationManager.getApplication().executeOnPooledThread(() -> { + VFSTestFrameworkListener.getInstance().updateAllTestFrameworks(sdk); + }); break; } - } } } diff --git a/python/src/com/jetbrains/python/testing/VFSTestFrameworkListener.java b/python/src/com/jetbrains/python/testing/VFSTestFrameworkListener.java index d193dc2aabc9..943a0b519534 100644 --- a/python/src/com/jetbrains/python/testing/VFSTestFrameworkListener.java +++ b/python/src/com/jetbrains/python/testing/VFSTestFrameworkListener.java @@ -94,23 +94,27 @@ public class VFSTestFrameworkListener { } public void updateAllTestFrameworks(final Sdk sdk) { - updateTestFrameworks(sdk, PyNames.PY_TEST); - updateTestFrameworks(sdk, PyNames.NOSE_TEST); - updateTestFrameworks(sdk, PyNames.AT_TEST); - myQueue.flush(); + checkFrameworkInstalledAndUpdateSettings(sdk, PyNames.PY_TEST); + checkFrameworkInstalledAndUpdateSettings(sdk, PyNames.NOSE_TEST); + checkFrameworkInstalledAndUpdateSettings(sdk, PyNames.AT_TEST); } public void updateTestFrameworks(final Sdk sdk, final String testPackageName) { myQueue.queue(new Update(Pair.create(sdk, testPackageName)) { @Override public void run() { - final Boolean installed = isTestFrameworkInstalled(sdk, testPackageName); - if (installed != null) ApplicationManager.getApplication().invokeLater( ( ()-> testInstalled(installed, sdk.getHomePath(), testPackageName))); - + checkFrameworkInstalledAndUpdateSettings(sdk, testPackageName); } }); } + private void checkFrameworkInstalledAndUpdateSettings(Sdk sdk, String testPackageName) { + final Boolean installed = isTestFrameworkInstalled(sdk, testPackageName); + if (installed != null) { + ApplicationManager.getApplication().invokeLater(() -> testInstalled(installed, sdk.getHomePath(), testPackageName)); + } + } + /** * @return null if we can't be sure */