ui: do not leak disposed Content via layout after toolwindow deactivation

Disposed Content was accessible via myLastLayout.toDrop collection.

GitOrigin-RevId: 8dcc2647e374c46848cbfa50b2c92951defc32ef
This commit is contained in:
Aleksey Pivovarov
2020-05-04 18:46:22 +00:00
committed by intellij-monorepo-bot
parent 4d255bbce6
commit 3427858d90
3 changed files with 12 additions and 1 deletions
@@ -8,7 +8,6 @@ import com.intellij.ide.actions.*
import com.intellij.ide.impl.ContentManagerWatcher
import com.intellij.idea.ActionsBundle
import com.intellij.internal.statistic.eventLog.EventPair
import com.intellij.internal.statistic.eventLog.FeatureUsageData
import com.intellij.notification.EventLog
import com.intellij.openapi.Disposable
import com.intellij.openapi.actionSystem.*
@@ -321,6 +320,10 @@ internal class ToolWindowImpl(val toolWindowManager: ToolWindowManagerImpl,
if (isAvailable != value) {
isAvailable = value
toolWindowManager.toolWindowPropertyChanged(this, ToolWindowProperty.AVAILABLE)
if (!value) {
contentUi?.dropCaches()
}
}
}
@@ -87,6 +87,10 @@ final class TabContentLayout extends ContentLayout implements MorePopupAware {
return myLastLayout.moreRect;
}
public void dropCaches() {
myLastLayout = null;
}
@Override
public boolean canShowMorePopup() {
return getMoreRect() != null;
@@ -225,6 +225,10 @@ public final class ToolWindowContentUi implements ContentUI, DataProvider {
contentComponent.repaint();
}
public void dropCaches() {
tabsLayout.dropCaches();
}
private void rebuild() {
getCurrentLayout().rebuild();
getCurrentLayout().update();