[tabs] dispose specific tab when closing
authorJulia Beliaeva <Julia.Beliaeva@jetbrains.com>
Fri, 29 Apr 2016 12:39:18 +0000 (15:39 +0300)
committerJulia Beliaeva <Julia.Beliaeva@jetbrains.com>
Tue, 3 May 2016 16:32:39 +0000 (19:32 +0300)
platform/platform-impl/src/com/intellij/util/ContentUtilEx.java

index acec06ed9ac52dbfc436348b61fbcf2a3073e582..3f3ad3e5d6cb9385e2728eef5d7872cd115579ed 100644 (file)
@@ -126,12 +126,20 @@ public class ContentUtilEx extends ContentsUtil {
         JComponent component = tabbedContent.getComponent();
         tabbedContent.removeContent(component);
         contentManager.setSelectedContent(tabbedContent, true, true);
+        dispose(component);
         return;
       }
     }
     contentManager.removeContent(content, true);
   }
 
+  private static void dispose(@NotNull JComponent component) {
+    Object disposable = component.getClientProperty(DISPOSABLE_KEY);
+    if (disposable != null && disposable instanceof Disposable) {
+      Disposer.dispose((Disposable)disposable);
+    }
+  }
+
   @NotNull
   public static String getFullName(@NotNull String groupPrefix, @NotNull String tabName) {
     return getFullPrefix(groupPrefix) + tabName;