fix leak in SearchTextField IDEA-273465

GitOrigin-RevId: e5e29ca1dba274677d35113ef96701e25c3544dc
This commit is contained in:
Elena.Korotkova
2021-07-13 15:57:11 +00:00
committed by intellij-monorepo-bot
parent 60a8e34003
commit dc01e16f93
@@ -44,6 +44,7 @@ public class SearchTextField extends JPanel {
private JBPopup myPopup;
private String myHistoryPropertyName;
private final boolean historyPopupEnabled;
private boolean init = true;
public SearchTextField() {
this(true);
@@ -152,6 +153,7 @@ public class SearchTextField extends JPanel {
DumbAwareAction.create(event -> {
showPopup();
}).registerCustomShortcutSet(KeymapUtil.getActiveKeymapShortcuts("ShowSearchHistory"), myTextField);
init = false;
}
@Override
@@ -378,14 +380,16 @@ public class SearchTextField extends JPanel {
}
private void reInitPopup() {
hidePopup();
final JList<String> list = new JBList<>(myModel);
final Runnable chooseRunnable = createItemChosenCallback(list);
if(ApplicationManager.getApplication() != null && JBPopupFactory.getInstance() != null) {
myPopup = JBPopupFactory.getInstance().createListPopupBuilder(list)
.setMovable(false)
.setRequestFocus(true)
.setItemChoosenCallback(chooseRunnable).createPopup();
if(!init) {
hidePopup();
final JList<String> list = new JBList<>(myModel);
final Runnable chooseRunnable = createItemChosenCallback(list);
if (ApplicationManager.getApplication() != null && JBPopupFactory.getInstance() != null) {
myPopup = JBPopupFactory.getInstance().createListPopupBuilder(list)
.setMovable(false)
.setRequestFocus(true)
.setItemChoosenCallback(chooseRunnable).createPopup();
}
}
}