Bug 311396 NPE thrown when trying to close a part that hasn't been restored
An NPE is thrown because we try to ask the part for a context. However, if the part hasn't been rendered yet, we'll get null back. java.lang.NullPointerException at org.eclipse.e4.workbench.ui.renderers.swt.StackRenderer$6.close(StackRenderer.java:449) at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1590) at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:261) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657) at org.eclipse.e4.ui.workbench.swt.internal.PartRenderingEngine$4.run(PartRenderingEngine.java:517) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.e4.ui.workbench.swt.internal.PartRenderingEngine.run(PartRenderingEngine.java:455) at org.eclipse.e4.workbench.ui.internal.E4Workbench.createAndRunUI(E4Workbench.java:100) at org.eclipse.ui.internal.Workbench$3.run(Workbench.java:533) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:519) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:600) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574) at org.eclipse.equinox.launcher.Main.run(Main.java:1407) at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/workbench/ui/renderers/swt/StackRenderer.java
});
		folderContext.runAndTrack(updateActiveTab, null);
		return newWidget;
	}
	protected void createTab(MElementContainer<MUIElement> stack,
			MUIElement part) {
		MUILabel itemPart = (MUILabel) part;
		CTabFolder ctf = (CTabFolder) stack.getWidget();
		CTabItem cti = findItemForPart(part);
		if (cti != null) {
			if (part.getWidget() != null)
				cti.setControl((Control) part.getWidget());
			return;
		}
		int createFlags = SWT.NONE;
		if (part instanceof MPart && ((MPart) part).isCloseable()) {
			createFlags |= SWT.CLOSE;
		}
		
		int index = calcIndexFor(stack, part);
		cti = new CTabItem(ctf, createFlags, index);
		cti.setData(OWNING_ME, part);
		cti.setText(getLabel(itemPart, itemPart.getLabel()));
		cti.setImage(getImage(itemPart));
		cti.setToolTipText(itemPart.getTooltip());
		if (part.getWidget() != null) {
			
			
			Control ctrl = (Control) part.getWidget();
			if (ctrl.getParent() == ctf)