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
container.getChildren().add(partB);
		container.getChildren().add(partC);
		wb = new E4Workbench(application, appContext);
		wb.createAndRunUI(window);
		
		
		container.setSelectedElement(partA);
		partB.setToBeRendered(false);
		assertTrue(
				"Changing the TBR of a non-selected element should not change the value of the container's seletedElement",
				container.getSelectedElement() == partA);
		
		
		container.setSelectedElement(partA);
		partA.setToBeRendered(false);
		assertTrue(
				"Changing the TBR of the selected element should have set the field to null",
				container.getSelectedElement() == null);
	}
	public void testSelectedElementNullingParentChange() {
		MApplication application = ApplicationFactoryImpl.eINSTANCE
				.createApplication();
		application.setContext(appContext);
		appContext.set(MApplication.class.getName(), application);
		MWindow window = BasicFactoryImpl.eINSTANCE.createWindow();
		application.getChildren().add(window);
		MPartSashContainer container = BasicFactoryImpl.eINSTANCE
				.createPartSashContainer();
		window.getChildren().add(container);
		MPart partA = BasicFactoryImpl.eINSTANCE.createPart();