void (@NotNull Project project, @NotNull Disposable parentDisposable) { EditorTextField field = ObjectUtils.tryCast(getEditorComponent(), EditorTextField.class); if (field == null) return; Disposable disposable = Disposer.newDisposable("XDebuggerExpressionComboBox Disposable"); Disposer.register(parentDisposable, () -> { // In case the project is closing this block is called // from the BaseContentCloseListener#disposeContent // and then removes editor with EditorComboBox#releaseLater. // The latter causes a false-positive exception (IDEA-273987) that editor is not released // when validation is running (see IDEA-285001). // Until IDEA-285001 is fixed this one is scheduled for next EDT call // to let Disposer.register(session.getProject(), disposable) dispose an editor // with correct way when project is closed. // If this one is triggered because the tool window is closed // then it's ok to release it later. ApplicationManager.getApplication().invokeLater(() -> Disposer.dispose(disposable)); }); Disposer.register(project, disposable); field.setDisposedWith(disposable); }