Bug 318363 [UI] Closing Perspectives changes others
If you open the Debug perspective and then close it the Package Explorer disappears. Root cause was that I opened the second perspective using the perspective switcher which performed the operation 'locally' rather than going through the WorkbenchPage#setPerspective code. This meant that the 'openPerspectives' list wasn't updated which meant that the 'closePerspective' call delegated to 'closeAllPerspectives' since it thought there was only one open.
bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/ToolControlRenderer.java
|| !(parent instanceof ToolBar || parent instanceof Composite))
			return null;
		MToolControl toolControl = (MToolControl) element;
		Widget parentWidget = (Widget) parent;
		IEclipseContext parentContext = getContextForParent(element);
		ToolItem sep = null;
		if (parent instanceof ToolBar) {
			sep = new ToolItem((ToolBar) parentWidget, SWT.SEPARATOR);
		}
		final Composite newComposite = new Composite((Composite) parentWidget,
				SWT.NONE);
		newComposite.setLayout(new FillLayout());
		
		IEclipseContext localContext = parentContext.createChild("TrimControl"); 
		IContributionFactory contributionFactory = (IContributionFactory) localContext
				.get(IContributionFactory.class.getName());
		localContext.set(Composite.class.getName(), newComposite);
		localContext.set(MToolControl.class.getName(), toolControl);
		Object tcImpl = contributionFactory.create(
				toolControl.getContributionURI(), localContext);
		toolControl.setObject(tcImpl);
		if (sep != null) {
			sep.setControl(newComposite);
			newComposite.pack();
			sep.setWidth(newComposite.getSize().x);
		}
		return newComposite;
	}
}