From ab06a7362b57f51f7be59c594868c95c4b5f1d41 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Tue, 2 Jun 2015 17:10:02 +0200 Subject: [PATCH] Fix missing context menu if Terminal is created while invisible --- .../tm/terminal/view/ui/tabs/TabFolderMenuHandler.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/tabs/TabFolderMenuHandler.java b/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/tabs/TabFolderMenuHandler.java index e406040a8b5..2e08efd6cfd 100644 --- a/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/tabs/TabFolderMenuHandler.java +++ b/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/tabs/TabFolderMenuHandler.java @@ -175,6 +175,11 @@ public class TabFolderMenuHandler extends PlatformObject { // Create the context menu contextMenu = contextMenuManager.createContextMenu(tabFolder); + // Temporarily set the menu on the tab folder to avoid the case + // where the menu has a different parent shell than the control. + // This can be the case if the tab folder is re-parented to the + // "PartRenderingEngine's limbo". + tabFolder.setMenu(contextMenu); // Create the context menu action instances doCreateContextMenuActions(); @@ -375,10 +380,11 @@ public class TabFolderMenuHandler extends PlatformObject { if (MenuManager.class.isAssignableFrom(adapter)) { return contextMenuManager; } else if (Menu.class.isAssignableFrom(adapter)) { - if (contextMenu != null && contextMenu.isDisposed()) { - // menu got disposed (should not happen) + if (contextMenu == null || contextMenu.isDisposed()) { contextMenu = contextMenuManager.createContextMenu(getTabFolder()); } + // Clear the menu from the tab folder now - see initialize() + getTabFolder().setMenu(null); return contextMenu; }