[r=kb] memory leak fixes

This commit is contained in:
Maxim Shafirov
2011-12-05 15:02:15 +04:00
parent 84478438fe
commit 1f23970ca2
2 changed files with 18 additions and 1 deletions
@@ -20,10 +20,13 @@
package com.intellij.ui;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.impl.ProjectLifecycleListener;
import com.intellij.psi.util.PsiModificationTracker;
import com.intellij.util.Function;
import com.intellij.util.messages.MessageBus;
import com.intellij.util.messages.MessageBusConnection;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.HashMap;
@@ -42,6 +45,12 @@ public class IconDeferrerImpl extends IconDeferrer {
clear();
}
});
connection.subscribe(ProjectLifecycleListener.TOPIC, new ProjectLifecycleListener.Adapter() {
@Override
public void afterProjectClosed(@NotNull Project project) {
clear();
}
});
}
private void clear() {
@@ -1183,7 +1183,9 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
button.dispose();
myId2StripeButton.remove(id);
//
myId2FocusWatcher.remove(id);
ToolWindowFocusWatcher watcher = (ToolWindowFocusWatcher)myId2FocusWatcher.remove(id);
watcher.deinstall();
// Destroy decorator
final InternalDecorator decorator = getInternalDecorator(id);
decorator.dispose();
@@ -1946,11 +1948,17 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
*/
private final class ToolWindowFocusWatcher extends FocusWatcher {
private final String myId;
private final ToolWindowImpl myToolWindow;
private ToolWindowFocusWatcher(final ToolWindowImpl toolWindow) {
myId = toolWindow.getId();
install(toolWindow.getComponent());
myToolWindow = toolWindow;
}
public void deinstall() {
deinstall(myToolWindow.getComponent());
}
protected boolean isFocusedComponentChangeValid(final Component comp, final AWTEvent cause) {