Bug 320158 [Compatibility] NPEs when closing and reopening perspective
1. Open a fresh e4 workbench 2. Close the Java perspective via the menu (Window > ...) 3. Open the Java perspective again via the perspective switcher Result: Several ERRORs and stack traces on the console (in the host Eclipse): Note: The NPEs do not occur when the perspective is closed via the context menu of the perspective switcher.
bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/perspectiveswitcher/PerspectiveSwitcher.java
});
		
		psTB.pack();
		psTB.getShell().layout(new Control[] { psTB }, SWT.DEFER);
		return psItem;
	}
	
	private IPerspectiveDescriptor getDescriptorFor(String id) {
		return PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId(id);
	}
	private MPerspective getPerspectiveFor(IPerspectiveDescriptor desc) {
		MPerspectiveStack stack = getPerspectiveStack();
		if (stack != null) {
			
			for (MPerspective persp : stack.getChildren()) {
				if (persp.getElementId().equals(desc.getId())) {
					return persp;
				}
			}
		}
		return null;
	}
	
	
	private void openPerspective(PerspectiveDescriptor desc) {
		IWorkbenchPage page = window.getContext().get(IWorkbenchPage.class);
		page.setPerspective(desc);
	}
	private void selectPerspective() {
		SelectPerspectiveDialog dialog = new SelectPerspectiveDialog(psTB.getShell(), PlatformUI