mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
project leak via toolbar->icon->DeferredIcon.evaluator->RunManager$1->project
This commit is contained in:
+8
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,19 +17,19 @@ package com.intellij.openapi.actionSystem.impl;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PresentationFactory {
|
||||
private final WeakHashMap<AnAction,Presentation> myAction2Presentation;
|
||||
|
||||
public PresentationFactory() {
|
||||
myAction2Presentation = new WeakHashMap<AnAction, Presentation>();
|
||||
}
|
||||
// Presentation can leak icon which can leak com.intellij.ui.DeferredIconImpl.myEvaluator which can leak enclosing class instance which can leak Project
|
||||
private final Map<AnAction, Presentation> myAction2Presentation = ContainerUtil.createWeakKeySoftValueMap();
|
||||
|
||||
@NotNull
|
||||
public final Presentation getPresentation(@NotNull AnAction action){
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
Presentation presentation = myAction2Presentation.get(action);
|
||||
if (presentation == null || !action.isDefaultIcon()){
|
||||
Presentation templatePresentation = action.getTemplatePresentation();
|
||||
@@ -50,6 +50,7 @@ public class PresentationFactory {
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
myAction2Presentation.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,6 +147,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener {
|
||||
*/
|
||||
public final void removeNotify(){
|
||||
myUISettings.removeUISettingsListener(this);
|
||||
removeToolbar();
|
||||
super.removeNotify();
|
||||
}
|
||||
|
||||
@@ -187,15 +188,20 @@ public class IdeRootPane extends JRootPane implements UISettingsListener {
|
||||
}
|
||||
|
||||
void updateToolbar() {
|
||||
if (myToolbar != null) {
|
||||
myNorthPanel.remove(myToolbar);
|
||||
}
|
||||
removeToolbar();
|
||||
myToolbar = createToolbar();
|
||||
myNorthPanel.add(myToolbar, 0);
|
||||
updateToolbarVisibility();
|
||||
myContentPane.revalidate();
|
||||
}
|
||||
|
||||
private void removeToolbar() {
|
||||
if (myToolbar != null) {
|
||||
myNorthPanel.remove(myToolbar);
|
||||
myToolbar = null;
|
||||
}
|
||||
}
|
||||
|
||||
void updateNorthComponents() {
|
||||
for (IdeRootPaneNorthExtension northComponent : myNorthComponents) {
|
||||
northComponent.revalidate();
|
||||
|
||||
Reference in New Issue
Block a user