From d93d0abce8dce52f256f6beafe3f440ef425513f Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Mon, 21 Jul 2014 14:00:37 +0400 Subject: [PATCH] Workaround for another JDK bug in cached popups. --- .../src/com/intellij/ui/popup/AbstractPopup.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java index 6bfc56df4399..da79ae1f769d 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java @@ -764,7 +764,16 @@ public class AbstractPopup implements JBPopup { popupOwner = root.getRootPane(); } myPopup = factory.getPopup(popupOwner, myContent, targetBounds.x, targetBounds.y, this); - + myPopup.getWindow().setSize(0, 0); + Container parent = myContent.getParent(); + if (parent.getComponentCount() > 1) { + // JDK uses cached heavyweight popup without removing other components + for (Component component : parent.getComponents()) { + if (component != myContent) { + parent.remove(component); + } + } + } if (myResizable) { final JRootPane root = myContent.getRootPane(); final IdeGlassPaneImpl glass = new IdeGlassPaneImpl(root); @@ -805,11 +814,7 @@ public class AbstractPopup implements JBPopup { listener.beforeShown(new LightweightWindowEvent(this)); } - // can be improved by moving in myPopup code - myPopup.getWindow().pack(); - myPopup.setRequestFocus(myRequestFocus); - LOG.debug("popup window size: " + myPopup.getWindow().getSize()); myPopup.show(); final Window window = SwingUtilities.getWindowAncestor(myContent);