Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-ui-dev] IMenuCreator.dispose() not being called [2.0.1]


I cannot find any code in the Workbench that calls IMenuCreator.dispose().  I have created a drop-down Action similar to the NewWizardDropDownAction.

ActionContributionItem asks for the menu (getMenu(Control)), but then it never calls dispose on the IMenuCreator.  And I don't think it calls dispose on the Menu either.  The SWT Menu will stay around for a long time, even if the Action it removed from the Toolbar.  The SWT Menu goes away only if the User closes the WorkbenchWindow.  SWT is keeping track of all menus hosted by a Shell, and it disposes them if they are still hanging around.

If this is still true, it looks like the fix would be in ActionContributionItem#handleWidgetDispose().  It should see if the style is DROP_DOWN, and ask the IMenuCreator to dispose().

private void handleWidgetDispose(Event e) {
>        if (action.getStyle() == IAction.AS_DROP_DOWN_MENU)
>                action.getMenuCreator().dipose();
        if (e.widget == widget) {
                // the item is being disposed
                action.removePropertyChangeListener(listener);
                widget = null;
        }
}

Back to the top