Bug 331685 Unset context from model if widget creation failed since the context is disposed
If the renderer fails to create a widget for a given element, it will dispose its created context (if any) prior to returning from the call. If we try to deconstruct the element later, it will fail with an NPE because the context has been disposed and getParent() will return null.
tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/workbench/PartRenderingEngineTests.java
partA.setElementId("partA");
		partA.setContributionURI("platform:/plugin/org.eclipse.e4.ui.tests/org.eclipse.e4.ui.tests.workbench.SampleView");
		MPart partB = BasicFactoryImpl.eINSTANCE.createPart();
		partB.setElementId("partB");
		partB.setContributionURI("platform:/plugin/org.eclipse.e4.ui.tests/org.eclipse.e4.ui.tests.workbench.SampleView");
		MPart partC = BasicFactoryImpl.eINSTANCE.createPart();
		partC.setElementId("partC");
		partC.setContributionURI("platform:/plugin/org.eclipse.e4.ui.tests/org.eclipse.e4.ui.tests.workbench.SampleView");
		container.getChildren().add(partA);
		container.getChildren().add(partB);
		container.getChildren().add(partC);
		wb = new E4Workbench(application, appContext);
		wb.createAndRunUI(window);
		
		
		container.setSelectedElement(partA);
		container.getChildren().remove(partB);
		assertTrue(
				"Changing the parent of a non-selected element should not change the value of the container's seletedElement",
				container.getSelectedElement() == partA);
		
		
		container.setSelectedElement(partA);
		container.getChildren().remove(partA);
		assertTrue(
				"Changing the parent of the selected element should have set the field to null",
				container.getSelectedElement() == null);
	}
	public void testCreateGuiBug301950() {
		MApplication application = ApplicationFactoryImpl.eINSTANCE