Community
Participate
Working Groups
When I use SWTBotEclipseEditor editor = ... editor.contextMenu("Rename Element").click(); I get a "Widget is disposed error". Same if I try to access the accelerator form the context menu item.
I had a look at source, and couldn't find a Unit-test for this use-case, so it might indeed be broken... If you wish to contribute a test Case and a patch, you'd be very welcome ;) http://wiki.eclipse.org/SWTBot/Contributing
Workaround: Instead of calling editor.contextMenu("Rename Element").click(); I call new SWTBotMenu(ContextMenuHelper.contextMenu(editor.styledText, text)).click(); Maybe we should patch SWTBotEclipseEditor like public SWTBotMenu contextMenu(String text) throws WidgetNotFoundException { return new SWTBotMenu(ContextMenuHelper.contextMenu(styledText, text)); }
It seems to be a valid workaround, but it seems like this error is actually a consequence of a bug in AbstractSWTBot.contextMenu . It would be better to find the root cause, and fix it in the lowest layer possible.
The workaround was copied from SWTBotTreeItem.contextMenu(). Just for the record.
See also http://www.eclipse.org/forums/index.php/m/1105765/#msg_1105765
(In reply to Jan Koehnlein from comment #4) > The workaround was copied from SWTBotTreeItem.contextMenu(). Just for the > record. Difference of implementation can be explained by the face that default AbstractSWTBot.contextMenu implementation should work on all SWT Control (including StyledText), whereas TreeItem and *Item in general are not Controls and need an alternative implementation. But that's an interesting hint.
This looks similar to https://bugs.eclipse.org/bugs/show_bug.cgi?id=384621 where ContextMenuHelper was introduced
Pushed fix suggested above to gerrit. https://git.eclipse.org/r/#/c/17862/
Ingo's patch was tested successfully and merged. Thanks for this contribution!
Just curious: Any reason why my patch has been accepted now? What removed your doubts?
(In reply to Jan Koehnlein from comment #10) > Just curious: Any reason why my patch has been accepted now? What removed > your doubts? There is no valid reason, and I still believe (but I'm not sure) that there is a better way to fix this bug. However, the patch came as a Gerrit contribution, with some unit tests to highlight bug and efficiency of the fix, and Hudson validated it. So it is good enough to be merged. Refactorings and improvements on the same line of code are still welcome. I guess if your patch was pushed to Gerrit with some unit tests, it would have been merged as well.