Bug 343536 [Compatibility] getOpenPerspectives() may have a null value as one of its array element
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java
index 8c9c666..f697eea 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java
@@ -3414,7 +3414,11 @@
 				.size()];
 		int count = 0;
 		for (MPerspective persp : perspectiveStack.getChildren()) {
-			IPerspectiveDescriptor desc = registry.findPerspectiveWithId(persp.getElementId());
+			String perspectiveId = persp.getElementId();
+			IPerspectiveDescriptor desc = registry.findPerspectiveWithId(perspectiveId);
+			if (desc == null) {
+				desc = new PerspectiveDescriptor(perspectiveId, persp.getLabel());
+			}
 			descs[count++] = desc;
 		}
 		return descs;
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveDescriptor.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveDescriptor.java
index b326871..1b8a5d0 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveDescriptor.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveDescriptor.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -44,6 +44,10 @@
 	private ImageDescriptor image;
 	private IConfigurationElement element;
 
+	public PerspectiveDescriptor(String id, String label) {
+		this(id, label, null);
+	}
+
 	PerspectiveDescriptor(String id, String label, IConfigurationElement element) {
 		this.id = id;
 		this.label = label;
@@ -85,15 +89,12 @@
 	 */
 	public ImageDescriptor getImageDescriptor() {
 		if (image == null) {
+			image = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_ETOOL_DEF_PERSPECTIVE);
 			if (element != null) {
 				String icon = element.getAttribute(IWorkbenchRegistryConstants.ATT_ICON);
 				if (icon != null) {
-					image = AbstractUIPlugin.imageDescriptorFromPlugin(element
-							.getNamespaceIdentifier(), icon);
-				}
-				if (image == null) {
-					image = WorkbenchImages
-							.getImageDescriptor(ISharedImages.IMG_ETOOL_DEF_PERSPECTIVE);
+					image = AbstractUIPlugin.imageDescriptorFromPlugin(
+							element.getNamespaceIdentifier(), icon);
 				}
 			}
 		}