[r332] Bug 198428 - Deadlock deleting launch configuration
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java index 06643bb..c398221 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java
@@ -253,31 +253,29 @@ DebugUIPlugin.log(e); return; } + //due to notification and async messages we need to collect the moved from config + //now, else it is null'd out before the following async job runs + //@see bug 211235 - making local config shared creates "non-existant dup" in LCD + final ILaunchConfiguration from = getLaunchManager().getMovedFrom(configuration); + // handle asynchronously: @see bug 198428 - Deadlock deleting launch configuration Display display = DebugUIPlugin.getStandardDisplay(); - if (display.getThread() == Thread.currentThread()) { - // If we're already in the UI thread (user pressing New in the - // dialog), update the tree immediately. - handleConfigurationAdded(configuration); - } else { - display.asyncExec(new Runnable() { - public void run() { - handleConfigurationAdded(configuration); - } - }); - } + display.asyncExec(new Runnable() { + public void run() { + handleConfigurationAdded(configuration, from); + } + }); } /** * The given launch configuration has been added. Add it to the tree. * @param configuration the added configuration */ - private void handleConfigurationAdded(final ILaunchConfiguration configuration) { + private void handleConfigurationAdded(ILaunchConfiguration configuration, ILaunchConfiguration from) { TreeViewer viewer = getTreeViewer(); if (viewer != null) { try { viewer.add(configuration.getType(), configuration); // if moved, remove original now - ILaunchConfiguration from = getLaunchManager().getMovedFrom(configuration); if (from != null) { viewer.remove(from); } @@ -304,18 +302,13 @@ if (to != null) { return; } + // handle asynchronously: @see bug 198428 - Deadlock deleting launch configuration Display display = DebugUIPlugin.getStandardDisplay(); - if (display.getThread() == Thread.currentThread()) { - // If we're already in the UI thread (user pressing Delete in the - // dialog), update the tree immediately. - handleConfigurationRemoved(configuration); - } else { - display.asyncExec(new Runnable() { - public void run() { - handleConfigurationRemoved(configuration); - } - }); - } + display.asyncExec(new Runnable() { + public void run() { + handleConfigurationRemoved(configuration); + } + }); } /**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationViewer.java index b304aba..b0cb882 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationViewer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationViewer.java
@@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Iterator; +import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreePath; @@ -61,6 +62,11 @@ Object o = null; for(Iterator iter = selection.iterator(); iter.hasNext();) { o = iter.next(); + if(o instanceof ILaunchConfiguration) { + if(!((ILaunchConfiguration)o).exists()) { + continue; + } + } if(internalGetWidgetToSelect(o) != null) { if(!set.contains(o)) { set.add(o); @@ -85,9 +91,13 @@ if(indices[1] > -1) { index = selectIndex(pitem.getItemCount(), indices[1]); if(index > -1) { - Object d = pitem.getItem(index).getData(); - if(d != null) { - o = d; + ILaunchConfiguration config = null; + for(int i = index; i > -1; i--) { + config = (ILaunchConfiguration) pitem.getItem(i).getData(); + if(config != null && config.exists()) { + o = config; + break; + } } } else { @@ -226,7 +236,7 @@ * Finds the index of the specified object in the given array of tree items * @param items the items to search for the specified object * @param object the object to find the index of - * @return the index of the specified object inthe listing of tree items, or -1 if not found + * @return the index of the specified object in the listing of tree items, or -1 if not found */ private int indexOf(TreeItem[] items, Object object) { if(object != null) {