fixed bug #9228.
authorwpaul
Mon, 08 Jun 2009 12:51:27 -0500
changeset 24 b00fe9004252
parent 23 7357eeb2874f
child 25 68aa5b0d78d4
fixed bug #9228.
cdt/cdt_5_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java
--- a/cdt/cdt_5_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java	Fri Jun 05 16:58:02 2009 -0500
+++ b/cdt/cdt_5_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java	Mon Jun 08 12:51:27 2009 -0500
@@ -191,14 +191,29 @@
 
 	/**
 	 * Gets the list of executables in the workspace.
+	 * @param wait whether or not to wait if the list is being refreshed when this
+	 * method is called.  when true, this call will not return until the list is
+	 * complete.  when false, it will return with the last known list.  if calling
+	 * from any UI, you should not block the UI waiting for this to return, but rather
+	 * register as an {@link IExecutablesChangeListener} to get notifications when the
+	 * list changes.
 	 * @return the list of executables which may be empty
 	 */
-	public Collection<Executable> getExecutables() {
+	public Collection<Executable> getExecutables(boolean wait) {
 		
 		trace("getExecutables called at " + getStringFromTimestamp(System.currentTimeMillis()));
 
 		List<Executable> executables = new ArrayList<Executable>();
 
+		if (wait && refreshJob.getState() != Job.NONE) {
+			trace("waiting for refresh job to finish at " + getStringFromTimestamp(System.currentTimeMillis()));
+			try {
+				refreshJob.join();
+			} catch (InterruptedException e) {
+			}
+			trace("refresh job finished at " + getStringFromTimestamp(System.currentTimeMillis()));
+		}
+		
 		synchronized (executablesMap) {
 			for (List<Executable> exes : executablesMap.values()) {
 				for (Executable exe : exes) {
@@ -215,6 +230,15 @@
 	}
 
 	/**
+	 * Gets the list of executables in the workspace.  Equivalent to {@link ExecutablesManager}{@link #getExecutables(false)}.
+	 * Just kept for older API compatibility.
+	 * @return the list of executables which may be empty
+	 */
+	public Collection<Executable> getExecutables() {
+		return getExecutables(false);
+	}
+	
+	/**
 	 * Gets the collection of executables for the given project
 	 * @param project the project
 	 * @return collection of executables which may be empty