From 6b883c0fe3e7f6f52bad2a53b49b81e8b33d9ca8 Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Tue, 17 Jun 2008 13:48:12 +0400 Subject: [PATCH] NPE: auto selection in list popups caused to dispose in show() --- platform-impl/src/com/intellij/ui/popup/AbstractPopup.java | 8 +++++++- platform-impl/src/com/intellij/ui/popup/list/ListPopupImpl.java | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java b/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java index c9e21d7da7..dee13b9a45 100644 --- a/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java +++ b/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java @@ -506,12 +506,18 @@ public class AbstractPopup implements JBPopup, Disposable { assert ApplicationManager.getApplication().isDispatchThread(); final boolean shouldShow = beforeShow(); + if (!shouldShow) { + return; + } + if (myInStack) { myFocusTrackback = new FocusTrackback(this, owner, true); - myFocusTrackback.setMustBeShown(shouldShow); + myFocusTrackback.setMustBeShown(true); } + + Dimension sizeToSet = null; if (myDimensionServiceKey != null) { diff --git a/platform-impl/src/com/intellij/ui/popup/list/ListPopupImpl.java b/platform-impl/src/com/intellij/ui/popup/list/ListPopupImpl.java index d4617f5f2f..0ea6d75e64 100644 --- a/platform-impl/src/com/intellij/ui/popup/list/ListPopupImpl.java +++ b/platform-impl/src/com/intellij/ui/popup/list/ListPopupImpl.java @@ -67,7 +67,13 @@ public class ListPopupImpl extends WizardPopup implements ListPopup { myList.setVisibleRowCount(Math.min(myMaxRowCount, myListModel.getSize())); - return super.beforeShow() && (!myAutoHandleBeforeShow || !tryToAutoSelect(true)); + boolean shouldShow = super.beforeShow(); + if (myAutoHandleBeforeShow) { + final boolean toDispose = tryToAutoSelect(true); + shouldShow &= !toDispose; + } + + return shouldShow; } protected void afterShow() { -- 2.11.4.GIT