Which disposable to use for a component validator in a settings window?

Answered

I am validating my JBTextFields in my plugin settings component using the component validation described here.

However, it does not seem right to use the project as parent disposable when reading the disposer documentation here. But I am unsure which parent disposable to use in this case. The validators are only required as long as the settings window is open, but I am not sure which disposable corresponds to the settings window.

I am grateful for any suggestions.

 

9 comments
Comment actions Permalink

If you inherit from com.intellij.openapi.options.SettingsEditor, you can pass thisinstead.

1
Comment actions Permalink

Thanks, I changed it!

0
Comment actions Permalink

What is the proper parentDisposable for a SettingsEditor? Currently, I did not register it, and a memory leak is detected during the build.

0
Comment actions Permalink

Sorry for delay. What exactly is the problem/stacktrace?

0
Comment actions Permalink
Here is the stack trace:
2022-11-03 21:55:53,608 [  19582] SEVERE - #c.i.o.u.ObjectTree - Memory leak detected: 'no.hvl.tk.visual.debugger.settings.VisualDebuggerSettingsComponent@5734cfe8' of class no.hvl.tk.visual.debugger.settings.VisualDebuggerSettingsComponent is registered in Disposer but wasn't disposed.
Register it with a proper parentDisposable or ensure that it's always disposed by direct Disposer.dispose call.
See https://jetbrains.org/intellij/sdk/docs/basics/disposers.html for more details.
The corresponding Disposer.register() stacktrace is shown as the cause:

java.lang.RuntimeException: Memory leak detected: 'no.hvl.tk.visual.debugger.settings.VisualDebuggerSettingsComponent@5734cfe8' of class no.hvl.tk.visual.debugger.settings.VisualDebuggerSettingsComponent is registered in Disposer but wasn't disposed.
Register it with a proper parentDisposable or ensure that it's always disposed by direct Disposer.dispose call.
See https://jetbrains.org/intellij/sdk/docs/basics/disposers.html for more details.
The corresponding Disposer.register() stacktrace is shown as the cause:

    at com.intellij.openapi.util.ObjectNode.assertNoChildren(ObjectNode.java:41)
    at com.intellij.openapi.util.ObjectTree.assertIsEmpty(ObjectTree.java:210)
    at com.intellij.openapi.util.Disposer.assertIsEmpty(Disposer.java:232)
    at com.intellij.openapi.util.Disposer.assertIsEmpty(Disposer.java:227)
    at com.intellij.openapi.application.impl.ApplicationImpl.disposeContainer(ApplicationImpl.java:230)
    at com.intellij.openapi.application.impl.ApplicationImpl.disposeSelf(ApplicationImpl.java:247)
    at com.intellij.openapi.application.impl.ApplicationImpl.doExit(ApplicationImpl.java:676)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$exit$7(ApplicationImpl.java:632)
    at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:209)
    at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:21)
    at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:191)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:881)
    at com.intellij.openapi.application.impl.ApplicationImpl$3.run(ApplicationImpl.java:513)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:75)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:118)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:42)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:779)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:730)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:724)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:749)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:898)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:746)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:439)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:791)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:438)
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
    at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:604)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:436)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:881)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:484)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
Caused by: java.lang.Throwable
Caused by: java.lang.Throwable

    at com.intellij.openapi.util.ObjectNode.<init>(ObjectNode.java:24)
    at com.intellij.openapi.util.ObjectNode.findOrCreateChildNode(ObjectNode.java:165)
    at com.intellij.openapi.util.ObjectTree.register(ObjectTree.java:51)
    at com.intellij.openapi.util.Disposer.register(Disposer.java:117)
    at com.intellij.openapi.options.SettingsEditor.<init>(SettingsEditor.java:43)
    at com.intellij.openapi.options.SettingsEditor.<init>(SettingsEditor.java:38)
    at no.hvl.tk.visual.debugger.settings.VisualDebuggerSettingsComponent.<init>(VisualDebuggerSettingsComponent.java:19)
    at no.hvl.tk.visual.debugger.settings.VisualDebuggerSettingsConfigurable.createComponent(VisualDebuggerSettingsConfigurable.java:26)
    at com.intellij.openapi.options.ex.ConfigurableWrapper.createComponent(ConfigurableWrapper.java:169)
    at com.intellij.ide.ui.search.SearchUtil.processConfigurables(SearchUtil.java:72)
    at com.intellij.ide.ui.search.TraverseUIStarter.lambda$startup$0(TraverseUIStarter.java:118)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:308)
    ... 22 more
0
Comment actions Permalink

VisualDebuggerSettingsConfigurable should implement Disposable, then pass its instance (`this`) to VisualDebuggerSettingsComponent.addInputFieldValidator() into CTOR of ComponentValidator.

0
Comment actions Permalink

But when is the VisualDebuggerSettingsConfigurable registered for disposal?
I still get a similar stack trace after the changes:


The corresponding Disposer.register() stacktrace is shown as the cause:

java.lang.RuntimeException: Memory leak detected: 'no.hvl.tk.visual.debugger.settings.VisualDebuggerSettingsConfigurable@43da370c' of class no.hvl.tk.visual.debugger.settings.VisualDebuggerSettingsConfigurable is registered in Disposer but wasn't disposed.
Register it with a proper parentDisposable or ensure that it's always disposed by direct Disposer.dispose call.
See https://jetbrains.org/intellij/sdk/docs/basics/disposers.html for more details.
The corresponding Disposer.register() stacktrace is shown as the cause:

    at com.intellij.openapi.util.ObjectNode.assertNoChildren(ObjectNode.java:41)
    at com.intellij.openapi.util.ObjectTree.assertIsEmpty(ObjectTree.java:210)
    at com.intellij.openapi.util.Disposer.assertIsEmpty(Disposer.java:232)
    at com.intellij.openapi.util.Disposer.assertIsEmpty(Disposer.java:227)
    at com.intellij.openapi.application.impl.ApplicationImpl.disposeContainer(ApplicationImpl.java:230)
    at com.intellij.openapi.application.impl.ApplicationImpl.disposeSelf(ApplicationImpl.java:247)
    at com.intellij.openapi.application.impl.ApplicationImpl.doExit(ApplicationImpl.java:676)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$exit$7(ApplicationImpl.java:632)
    at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:209)
    at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:21)
    at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:191)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:881)
    at com.intellij.openapi.application.impl.ApplicationImpl$3.run(ApplicationImpl.java:513)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:75)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:118)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:42)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:779)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:730)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:724)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:749)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:898)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:746)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:439)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:791)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:438)
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
    at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:604)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:436)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:881)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:484)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
Caused by: java.lang.Throwable
    at com.intellij.openapi.util.ObjectNode.<init>(ObjectNode.java:24)
Caused by: java.lang.Throwable

    at com.intellij.openapi.util.ObjectNode.findOrCreateChildNode(ObjectNode.java:165)
    at com.intellij.openapi.util.ObjectTree.register(ObjectTree.java:51)
    at com.intellij.openapi.util.Disposer.register(Disposer.java:117)
    at com.intellij.openapi.ui.ComponentValidator.installOn(ComponentValidator.java:155)
    at no.hvl.tk.visual.debugger.settings.VisualDebuggerSettingsComponent.addInputFieldValidators(VisualDebuggerSettingsComponent.java:41)
    at no.hvl.tk.visual.debugger.settings.VisualDebuggerSettingsComponent.<init>(VisualDebuggerSettingsComponent.java:37)
    at no.hvl.tk.visual.debugger.settings.VisualDebuggerSettingsConfigurable.createComponent(VisualDebuggerSettingsConfigurable.java:30)
    at com.intellij.openapi.options.ex.ConfigurableWrapper.createComponent(ConfigurableWrapper.java:169)
    at com.intellij.ide.ui.search.SearchUtil.processConfigurables(SearchUtil.java:72)
    at com.intellij.ide.ui.search.TraverseUIStarter.lambda$startup$0(TraverseUIStarter.java:118)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:308)
    ... 22 more
0
Comment actions Permalink

Sorry for delay, will try to check ASAP again

0

Please sign in to leave a comment.