Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widget disposed error on paste #31

Open
AObuchow opened this issue Aug 8, 2020 · 4 comments
Open

Widget disposed error on paste #31

AObuchow opened this issue Aug 8, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@AObuchow
Copy link
Owner

AObuchow commented Aug 8, 2020

While testing out Sample Commadner on windows, I got the following stacktrace in the problem view.

org.eclipse.core.commands.ExecutionException: Error executing 'org.eclipse.ui.edit.paste': org.eclipse.swt.SWTException: Widget is disposed
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:170)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:488)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:487)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
	at org.eclipse.ui.internal.handlers.LegacyHandlerService.executeCommand(LegacyHandlerService.java:389)
	at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:785)
	at org.eclipse.ui.menus.CommandContributionItem.lambda$3(CommandContributionItem.java:762)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4213)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1037)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4030)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3630)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1158)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1047)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:658)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:557)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:154)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:150)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:657)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:594)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1447)
Caused by: org.eclipse.e4.core.di.InjectionException: org.eclipse.swt.SWTException: Widget is disposed
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:68)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:319)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:253)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:156)
	... 32 more
Caused by: org.eclipse.swt.SWTException: Widget is disposed
	at org.eclipse.swt.SWT.error(SWT.java:4723)
	at org.eclipse.swt.SWT.error(SWT.java:4638)
	at org.eclipse.swt.SWT.error(SWT.java:4609)
	at org.eclipse.swt.dnd.DND.error(DND.java:296)
	at org.eclipse.swt.dnd.DND.error(DND.java:241)
	at org.eclipse.swt.dnd.Clipboard.checkWidget(Clipboard.java:139)
	at org.eclipse.swt.dnd.Clipboard.getContents(Clipboard.java:331)
	at org.eclipse.swt.dnd.Clipboard.getContents(Clipboard.java:285)
	at com.aobuchow.sample.commander.FileClipBoard.paste(FileClipBoard.java:47)
	at com.aobuchow.sample.commander.editor.FileManagerEditor.paste(FileManagerEditor.java:532)
	at com.aobuchow.sample.commander.handlers.PasteHandler.execute(PasteHandler.java:17)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:283)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:97)
	at jdk.internal.reflect.GeneratedMethodAccessor62.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
	... 36 more

Seems the clipboard got disposed

@AObuchow AObuchow added the bug Something isn't working label Aug 8, 2020
@AObuchow
Copy link
Owner Author

AObuchow commented Aug 9, 2020

I believe the issue is that when a FIleManagerEditor was being disposed of, it'd dispose of the FileClipBoard.
The FileClipBoard should only be disposed when the plugin shuts down, although this was causing issues related to https://bugs.eclipse.org/bugs/show_bug.cgi?id=265741

@ingomohr have you run into this issue before by any chance?

@ingomohr
Copy link
Collaborator

ingomohr commented Aug 9, 2020

I believe the issue is that when a FIleManagerEditor was being disposed of, it'd dispose of the FileClipBoard.
The FileClipBoard should only be disposed when the plugin shuts down, although this was causing issues related to https://bugs.eclipse.org/bugs/show_bug.cgi?id=265741

@ingomohr have you run into this issue before by any chance?

@AObuchow No, not yet. I haven't checked the code yet, but maybe the FileClipBoard is bound to the dispose-listener of the FIleManagerEditor (if it has some).

@AObuchow
Copy link
Owner Author

AObuchow commented Aug 9, 2020

@ingomohr yes that was the issue :) now I just have to find out when/how to properly dispose the clipboard

@ingomohr
Copy link
Collaborator

ingomohr commented Aug 9, 2020

@ingomohr yes that was the issue :) now I just have to find out when/how to properly dispose the clipboard

IRC we dispose the Clipboard right away everytime we use it. For that I wrote a util class to e.g. push a StructuredSelection to the clipboard - using some ClipboardUtil.pushSelection(sel) which creates the Clipboard, pushes the given selection and then disposes the Clipboard again.

Maybe, there's a better option for this (the class is really old) - but it's working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants