Bug 529182 - NPE on opening second instance of call hierarchy from
editor

The code from bug 516403 works only if the current part is inside the
view stack, and fails badly if the current part is inside the editor
area.

Change-Id: I297a89305b7e0acbba11c0e38be1a7740a430d47
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java
index b610bfd..548c27c 100644
--- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java
+++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java
@@ -858,12 +858,17 @@
 			if (sharedPart == null) {
 				return null;
 			}
-			if (secondaryId && getActivePart() != null) {
-				MElementContainer<MUIElement> parent = getActivePart().getParent();
-				if (getActivePart().getCurSharedRef() != null) {
-					parent = getActivePart().getCurSharedRef().getParent();
+			MPart active = getActivePart();
+			if (secondaryId && active != null) {
+				MElementContainer<MUIElement> parent = active.getParent();
+				MPlaceholder sharedRef = active.getCurSharedRef();
+				if (sharedRef != null) {
+					parent = sharedRef.getParent();
 				}
 				while (!(MPerspective.class.isInstance(parent) || MWindow.class.isInstance(parent))) {
+					if (parent.getParent() == null) {
+						break;
+					}
 					parent = parent.getParent();
 				}