From 066324e6ef672f0b64a678c40e0f5832e4c8b3ba Mon Sep 17 00:00:00 2001 From: Gregory Shrago Date: Fri, 30 Oct 2009 17:41:24 +0300 Subject: [PATCH] nondisposed libraries fix --- .../src/com/intellij/util/ui/classpath/SimpleClasspathPanel.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/util/ui/classpath/SimpleClasspathPanel.java b/platform/lang-impl/src/com/intellij/util/ui/classpath/SimpleClasspathPanel.java index aa6db97240..05ee68ba51 100644 --- a/platform/lang-impl/src/com/intellij/util/ui/classpath/SimpleClasspathPanel.java +++ b/platform/lang-impl/src/com/intellij/util/ui/classpath/SimpleClasspathPanel.java @@ -163,12 +163,14 @@ public class SimpleClasspathPanel extends JPanel { list.scrollRectToVisible(cellRect); } - private static Collection ensureApplicationLevel(final Library library, final Set existingFiles) { + private static Collection ensureApplicationLevel(final Library library, final Set existingFiles, + final Disposable parentDisposable) { if (library.getTable() == null || !LibraryTablesRegistrar.APPLICATION_LEVEL.equals(library.getTable().getTableLevel())) { final ArrayList result = new ArrayList(); for (VirtualFile file : library.getFiles(OrderRootType.CLASSES)) { if (!existingFiles.add(file)) continue; final Library newLibrary = LibraryTableImplUtil.createModuleLevelLibrary(null, null); + Disposer.register(parentDisposable, newLibrary); final Library.ModifiableModel libModel = newLibrary.getModifiableModel(); libModel.addRoot(file, OrderRootType.CLASSES); libModel.commit(); @@ -264,7 +266,7 @@ public class SimpleClasspathPanel extends JPanel { final List libraries = dialog.getSelectedLibraries(); final ArrayList result = new ArrayList(); for (Library o : libraries) { - result.addAll(ensureApplicationLevel(o, existingFiles)); + result.addAll(ensureApplicationLevel(o, existingFiles, myDisposable)); } return result; } -- 2.11.4.GIT