[fleet] Python SDK library might be created before listener invocation

GitOrigin-RevId: d1ff30bb2f6c3d2764ca7cc0c22e34af2b4fd6a6
This commit is contained in:
Bernhard Geisberger
2023-12-19 02:01:31 +00:00
committed by intellij-monorepo-bot
parent 010a0b5a4d
commit 61550843c9
@@ -19,7 +19,17 @@ public class PythonSdkTableListener implements ProjectJdkTable.Listener {
public void jdkAdded(@NotNull final Sdk sdk) {
if (sdk.getSdkType() instanceof PythonSdkType) {
ApplicationManager.getApplication().invokeLater(() -> ApplicationManager.getApplication().runWriteAction(() -> {
addLibrary(sdk);
final ModifiableModelsProvider provider = ModifiableModelsProvider.getInstance();
final LibraryTable.ModifiableModel libraryTableModifiableModel = provider.getLibraryTableModifiableModel();
Library library = libraryTableModifiableModel.getLibraryByName(PythonFacetUtil.getFacetLibraryName(sdk.getName()));
provider.disposeLibraryTableModifiableModel(libraryTableModifiableModel);
if (library == null) {
addLibrary(sdk);
}
else {
// Library might already be created before listener invocation, e.g. by PythonFacetUtil.updateLibrary
updateLibrary(sdk);
}
}));
}
}