Console view ObjectNotDisposedException on IDE window close

I am building a plugin with a tool window. The tool window has com.intellij.execution.ui.ConsoleView element. Currently, there is ObjectNotDisposedException exception bubbles up when closing the IDE window.

stacktrace.txt:

com.intellij.openapi.util.TraceableDisposable.ObjectNotDisposedException: See stack trace responsible for creation of unreleased object below 
	at com.intellij.openapi.editor.impl.EditorImpl.<init>(EditorImpl.java:149)
	at com.intellij.openapi.editor.impl.EditorFactoryImpl.createEditor(EditorFactoryImpl.java:205)
	at com.intellij.openapi.editor.impl.EditorFactoryImpl.createViewer(EditorFactoryImpl.java:175)
	at com.intellij.execution.impl.ConsoleViewUtil.setupConsoleEditor(ConsoleViewUtil.java:63)
	at com.intellij.execution.impl.ConsoleViewImpl.doCreateConsoleEditor(ConsoleViewImpl.java:949)
	at com.intellij.execution.impl.ConsoleViewImpl.lambda$createConsoleEditor$12(ConsoleViewImpl.java:926)
	at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:973)
	at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:57)
	at com.intellij.execution.impl.ConsoleViewImpl.createConsoleEditor(ConsoleViewImpl.java:925)
	at com.intellij.execution.impl.ConsoleViewImpl.initConsoleEditor(ConsoleViewImpl.java:428)
	at com.intellij.execution.impl.ConsoleViewImpl.getComponent(ConsoleViewImpl.java:407)
	at com.xxxxxxxx.remoteLog.UserLogToolWindow.<init>(UserLogToolWindow.java:79)
	at com.xxxxxxxx.remoteLog.RemoteLogToolWindowFactory.register(RemoteLogToolWindowFactory.java:71)
	at com.xxxxxxxx.ide.component.ProjComponent.projectOpened(ProjComponent.java:58)
	at com.intellij.openapi.project.impl.ProjectManagerImpl.fireProjectOpened(ProjectManagerImpl.java:793)
	at com.intellij.openapi.project.impl.ProjectManagerImpl.lambda$null$6(ProjectManagerImpl.java:399)
	at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransactionAndWait$2(TransactionGuardImpl.java:165)
	at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
	at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransaction$1(TransactionGuardImpl.java:111)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.doRun(LaterInvocator.java:435)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:419)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:403)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
	at java.awt.EventQueue.access$500(EventQueue.java:98)
	at java.awt.EventQueue$3.run(EventQueue.java:715)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:719)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:668)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:363)
	at com.intellij.ide.IdeEventQueue.pumpEventsForHierarchy(IdeEventQueue.java:776)
	at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:202)
	at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:188)
	at com.intellij.openapi.application.impl.ApplicationImpl.runProcessWithProgressSynchronously(ApplicationImpl.java:606)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcessWithProgressSynchronously(CoreProgressManager.java:454)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcessWithProgressSynchronously(ProgressManagerImpl.java:110)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcessWithProgressSynchronously(CoreProgressManager.java:251)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcessWithProgressSynchronously(CoreProgressManager.java:205)
	at com.intellij.openapi.project.impl.ProjectManagerImpl.loadProjectUnderProgress(ProjectManagerImpl.java:448)
	at com.intellij.openapi.project.impl.ProjectManagerImpl.openProject(ProjectManagerImpl.java:423)
	at com.intellij.platform.PlatformProjectOpenProcessor.doOpenProject(PlatformProjectOpenProcessor.java:254)
	at com.intellij.ide.RecentProjectsManagerBase.doOpenProject(RecentProjectsManagerBase.java:578)
	at com.intellij.ide.RecentProjectsManagerBase.doReopenLastProject(RecentProjectsManagerBase.java:697)
	at com.intellij.ide.RecentProjectsManagerBase$MyAppLifecycleListener.appStarting(RecentProjectsManagerBase.java:742)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.util.messages.impl.MessageBusConnectionImpl.deliverMessage(MessageBusConnectionImpl.java:117)
	at com.intellij.util.messages.impl.MessageBusImpl.doPumpMessages(MessageBusImpl.java:397)
	at com.intellij.util.messages.impl.MessageBusImpl.pumpWaitingBuses(MessageBusImpl.java:358)
	at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:347)
	at com.intellij.util.messages.impl.MessageBusImpl.sendMessage(MessageBusImpl.java:324)
	at com.intellij.util.messages.impl.MessageBusImpl.access$200(MessageBusImpl.java:29)
	at com.intellij.util.messages.impl.MessageBusImpl$2.invoke(MessageBusImpl.java:196)
	at com.sun.proxy.$Proxy55.appStarting(Unknown Source)
	at com.intellij.idea.IdeaApplication$IdeStarter.lambda$main$1(IdeaApplication.java:372)
	at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
	at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransaction$1(TransactionGuardImpl.java:111)
	at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:120)
	at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:122)
	at com.intellij.idea.IdeaApplication$IdeStarter.main(IdeaApplication.java:370)
	at com.intellij.idea.IdeaApplication.lambda$run$1(IdeaApplication.java:211)
	at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:195)
	at com.intellij.idea.IdeaApplication.run(IdeaApplication.java:211)
	at com.intellij.idea.IdeaApplication.lambda$initApplication$0(IdeaApplication.java:74)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
	at java.awt.EventQueue.access$500(EventQueue.java:98)
	at java.awt.EventQueue$3.run(EventQueue.java:715)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:342)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

 

java.lang.Throwable at com.intellij.openapi.util.TraceableDisposable.kill(TraceableDisposable.java:49) at com.intellij.openapi.editor.impl.EditorImpl.release(EditorImpl.java:945) at com.intellij.openapi.editor.impl.EditorFactoryImpl.releaseEditor(EditorFactoryImpl.java:225) at com.intellij.openapi.editor.impl.EditorFactoryImpl.validateEditorsAreReleased(EditorFactoryImpl.java:96) at com.intellij.openapi.editor.impl.EditorFactoryImpl$1.lambda$beforeProjectLoaded$0(EditorFactoryImpl.java:67) at com.intellij.openapi.util.Disposer$1.execute(Disposer.java:48) at com.intellij.openapi.util.Disposer$1.execute(Disposer.java:44) at com.intellij.openapi.util.objectTree.ObjectNode$1.execute(ObjectNode.java:138) at com.intellij.openapi.util.objectTree.ObjectNode$1.execute(ObjectNode.java:107) at com.intellij.openapi.util.objectTree.ObjectTree.executeActionWithRecursiveGuard(ObjectTree.java:193) at com.intellij.openapi.util.objectTree.ObjectNode.execute(ObjectNode.java:107) at com.intellij.openapi.util.objectTree.ObjectNode$1.execute(ObjectNode.java:127) at com.intellij.openapi.util.objectTree.ObjectNode$1.execute(ObjectNode.java:107) at com.intellij.openapi.util.objectTree.ObjectTree.executeActionWithRecursiveGuard(ObjectTree.java:193) at com.intellij.openapi.util.objectTree.ObjectNode.execute(ObjectNode.java:107) at com.intellij.openapi.util.objectTree.ObjectTree.executeAll(ObjectTree.java:157) at com.intellij.openapi.util.Disposer.dispose(Disposer.java:129) at com.intellij.openapi.util.Disposer.dispose(Disposer.java:125) at com.intellij.openapi.project.impl.ProjectManagerImpl.lambda$closeProject$15(ProjectManagerImpl.java:701) at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1057) at com.intellij.openapi.project.impl.ProjectManagerImpl.closeProject(ProjectManagerImpl.java:695) at com.intellij.openapi.project.impl.ProjectManagerImpl.closeAndDispose(ProjectManagerImpl.java:719) at com.intellij.ide.impl.ProjectUtil.closeAndDispose(ProjectUtil.java:97) at com.intellij.platform.PlatformProjectOpenProcessor.doOpenProject(PlatformProjectOpenProcessor.java:190) at com.intellij.ide.RecentProjectsManagerBase.doOpenProject(RecentProjectsManagerBase.java:578) at com.intellij.ide.ReopenProjectAction.actionPerformed(ReopenProjectAction.java:73) at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:258) at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:275) at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.lambda$actionPerformed$0(ActionMenuItem.java:287) at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:283) at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:106) at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:277) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022) at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$0(ActionMenuItem.java:111) at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88) at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransaction$1(TransactionGuardImpl.java:111) at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:120) at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:122) at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:111) at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:524) at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:35) at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:546) at java.awt.Component.processMouseEvent(Component.java:6548) at javax.swing.JComponent.processMouseEvent(JComponent.java:3325) at java.awt.Component.processEvent(Component.java:6313) at java.awt.Container.processEvent(Container.java:2237) at java.awt.Component.dispatchEventImpl(Component.java:4903) at java.awt.Container.dispatchEventImpl(Container.java:2295) at java.awt.Component.dispatchEvent(Component.java:4725) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4889) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4526) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4467) at java.awt.Container.dispatchEventImpl(Container.java:2281) at java.awt.Window.dispatchEventImpl(Window.java:2746) at java.awt.Component.dispatchEvent(Component.java:4725) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764) at java.awt.EventQueue.access$500(EventQueue.java:98) at java.awt.EventQueue$3.run(EventQueue.java:715) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90) at java.awt.EventQueue$4.run(EventQueue.java:737) at java.awt.EventQueue$4.run(EventQueue.java:735) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) at java.awt.EventQueue.dispatchEvent(EventQueue.java:734) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:719) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:664) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:363) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

I register my toolwindow via custom com.intellij.openapi.components.ProjectComponent where on projectOpened() method call I register the tool window for specific project (project window)

I register tool window via

loogToolWindow = ToolWindowManager.getInstance(project).registerToolWindow("NAME");
logToolWindow.getContentManager().addContent(contentUser);

where contentUser is JPanel

public class UserLogToolWindow {
private final Logger LOG = Logger.getLogger(UserLogToolWindow.class.getName());
public ConsoleView consoleView;
private JPanel userLogToolWindowContent;
private JPanel toolbarPanel;
private JPanel consolePanel;
private JButton saveButtion;
private JLabel iconLabel;
private Project project;

/**
* @param project
* @param toolWindow
*/
public UserLogToolWindow(@NotNull Project project, @NotNull ToolWindow toolWindow) {
ActionTrace actionTrace = new ActionTraceImpl();
this.project = project;
toolbarPanel.setLayout(new BorderLayout());
consolePanel.setLayout(new BorderLayout());

final ActionGroup actionGroupLeft = (ActionGroup) ActionManager.getInstance().getAction(
Constants.USER_LOG_ACTION_GROUP_LEFT);
final ActionToolbar toolbarLeft = ActionManager.getInstance().createActionToolbar(
Constants.ACTION_TOOLBAR, actionGroupLeft, false);
toolbarPanel.add(toolbarLeft.getComponent(), BorderLayout.WEST);

consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();
consolePanel.add(consoleView.getComponent());

iconLabel.setSize(new Dimension(15, -1));
iconLabel.setIcon(RemoteLogIcons.NOTIFICATION_ICON);



/**
* Activate tool window
*/
public static void active(@NotNull Project project) {
ToolWindow logToolWindow = ToolWindowManager.getInstance(project).getToolWindow(Constants.LOG_TOOL_WINDOW);
if (logToolWindow != null) {
logToolWindow.getContentManager().setSelectedContent(logToolWindow.getContentManager().getContent(0));
}
}

/**
* Get tool window panel
*
* @return
*/
public JPanel getContent() {
return userLogToolWindowContent;
}
}

Any input and help are appreciated, thank you !

评论操作 固定链接

This exception indicates that the editor component wasn't properly disposed. In this case, the editor is part of ConsoleView's implementation, so disposing the editor is achieved via disposing the ConsoleView instance. The problem should be resolved by disposing it on project closing (either explicitly - by calling Disposer.dispose(consoleView), or declaratively - by registering it to be disposed with project using Disposer.register(project, consoleView) ).

0
评论操作 固定链接

Thank you Dmitry, issue is solved, you made my day!

0

请先登录再写评论。