Bug 572404 - synchronize access PerspectiveManager.fPerspectiveContexts

Creating a project while opening e.g. a console page can result in
concurrent PerspectiveManager.startup() and PerspectiveManager.saving().
This can cause a NullPointerException or a
ConcurrentModificationException, with bad timing.

This change moves the initPerspectives() call to before listeners are
registered in startup(). This avoids the race condition.

Change-Id: I1fc2300217a7b4832e8eb33bce14b0e4847112cb
Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java
index 75c153e..7466647 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java
@@ -281,9 +281,9 @@
 	 * launches to be registered.
 	 */
 	public void startup() {
+		initPerspectives();
 		DebugUIPlugin.getDefault().addSaveParticipant(this);
 		DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
-		initPerspectives();
 	}
 
 	/**