Bug 319011 NPE when closing editor after closing a perspective
bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java
int toInsertWeight = (int) ((ratio / 100.0) * relToWeight + 0.5);
				relToWeight = relToWeight - toInsertWeight;
				relTo.setContainerData(Integer.toString(relToWeight));
				toInsert.setContainerData(Integer.toString(toInsertWeight));
			}
		}
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.e4.ui.workbench.modeling.EModelService#detach(org.eclipse.e4.ui.model.application
	 * .MPartSashContainerElement)
	 */
	public void detach(MPartSashContainerElement element, int x, int y, int width, int height) {
		
		MUIElement curParent = element.getParent();
		while (curParent != null && !(curParent instanceof MPerspective)
				&& !(curParent instanceof MWindow))
			curParent = curParent.getParent();
		if (curParent == null)
			return; 
		MTrimmedWindow newWindow = BasicFactoryImpl.INSTANCE.createTrimmedWindow();
		
		newWindow.setX(x);
		newWindow.setY(y);
		newWindow.setWidth(width);
		newWindow.setHeight(height);
		element.getParent().getChildren().remove(element);
		MWindowElement uiRoot = wrapElementForWindow(element);