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
gc.setForeground(background);
		gc.drawLine(2, size.y - 1, size.x, size.y - 1);
		gradientTop.dispose();
		gc.setForeground(border);
		gc.drawPolyline(line2);
		gc.dispose();
		comp.setBackgroundImage(backgroundImage);
		if (oldBackgroundImage != null)
			oldBackgroundImage.dispose();
	}
	void dispose() {
		cleanUp();
		if (backgroundImage != null) {
			comp.setBackgroundImage(null);
			backgroundImage.dispose();
			backgroundImage = null;
		}
	}
	void disposeTBImages() {
		ToolItem[] items = psTB.getItems();
		for (int i = 0; i < items.length; i++) {
			Image image = items[i].getImage();
			if (image != null) {
				items[i].setImage(null);
				image.dispose();
			}
		}
	}
}