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.
This commit is contained in:
Mikhail Golubev
2016-06-27 16:45:24 +03:00
parent 1b4c9945cb
commit fc9ea9bc20
2 changed files with 15 additions and 9 deletions
@@ -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;
}
}
}
}
@@ -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
*/