1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-16 21:45:22 +02:00

Bug 241789 - [view model] RejectedExecutionException during shutdown of Eclipse while a debug session is active

This commit is contained in:
Anton Leherbauer 2008-09-11 07:25:36 +00:00
parent 83c49e7875
commit 41c8b18397
4 changed files with 60 additions and 20 deletions

View file

@ -165,9 +165,17 @@ public class PDAAdapterFactory implements IAdapterFactory, ILaunchesListener2
} }
} }
private Map<PDALaunch, LaunchAdapterSet> fLaunchAdapterSets = private static Map<PDALaunch, LaunchAdapterSet> fgLaunchAdapterSets =
Collections.synchronizedMap(new HashMap<PDALaunch, LaunchAdapterSet>()); Collections.synchronizedMap(new HashMap<PDALaunch, LaunchAdapterSet>());
static void disposeAdapterSet(ILaunch launch) {
synchronized(fgLaunchAdapterSets) {
if ( fgLaunchAdapterSets.containsKey(launch) ) {
fgLaunchAdapterSets.remove(launch).dispose();
}
}
}
public PDAAdapterFactory() { public PDAAdapterFactory() {
DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this); DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
} }
@ -183,11 +191,11 @@ public class PDAAdapterFactory implements IAdapterFactory, ILaunchesListener2
// it means that we have a new launch, and we have to create a // it means that we have a new launch, and we have to create a
// new set of adapters. // new set of adapters.
LaunchAdapterSet adapterSet; LaunchAdapterSet adapterSet;
synchronized(fLaunchAdapterSets) { synchronized(fgLaunchAdapterSets) {
adapterSet = fLaunchAdapterSets.get(launch); adapterSet = fgLaunchAdapterSets.get(launch);
if (adapterSet == null) { if (adapterSet == null) {
adapterSet = new LaunchAdapterSet(launch); adapterSet = new LaunchAdapterSet(launch);
fLaunchAdapterSets.put(launch, adapterSet); fgLaunchAdapterSets.put(launch, adapterSet);
} }
} }
@ -208,12 +216,7 @@ public class PDAAdapterFactory implements IAdapterFactory, ILaunchesListener2
// are still needed to populate the contents of the view. // are still needed to populate the contents of the view.
for (ILaunch launch : launches) { for (ILaunch launch : launches) {
if (launch instanceof PDALaunch) { if (launch instanceof PDALaunch) {
PDALaunch pdaLaunch = (PDALaunch)launch; disposeAdapterSet(launch);
synchronized(fLaunchAdapterSets) {
if ( fLaunchAdapterSets.containsKey(pdaLaunch) ) {
fLaunchAdapterSets.remove(pdaLaunch).dispose();
}
}
} }
} }
} }

View file

@ -16,6 +16,9 @@ import java.net.URL;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.eclipse.dd.examples.pda.launch.PDALaunch;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Color;
@ -67,6 +70,7 @@ public class PDAUIPlugin extends AbstractUIPlugin {
/** /**
* This method is called upon plug-in activation * This method is called upon plug-in activation
*/ */
@Override
public void start(BundleContext context) throws Exception { public void start(BundleContext context) throws Exception {
fContext = context; fContext = context;
super.start(context); super.start(context);
@ -79,7 +83,9 @@ public class PDAUIPlugin extends AbstractUIPlugin {
/** /**
* This method is called when the plug-in is stopped * This method is called when the plug-in is stopped
*/ */
@Override
public void stop(BundleContext context) throws Exception { public void stop(BundleContext context) throws Exception {
disposeAdapterSets();
super.stop(context); super.stop(context);
plugin = null; plugin = null;
fContext = null; fContext = null;
@ -99,6 +105,7 @@ public class PDAUIPlugin extends AbstractUIPlugin {
return fContext; return fContext;
} }
@Override
protected void initializeImageRegistry(ImageRegistry reg) { protected void initializeImageRegistry(ImageRegistry reg) {
declareImage(IMG_OBJ_PDA, PATH_OBJECT + "pda.gif"); declareImage(IMG_OBJ_PDA, PATH_OBJECT + "pda.gif");
} }
@ -134,4 +141,15 @@ public class PDAUIPlugin extends AbstractUIPlugin {
return color; return color;
} }
/**
* Dispose adapter sets for all launches.
*/
private void disposeAdapterSets() {
for (ILaunch launch : DebugPlugin.getDefault().getLaunchManager().getLaunches()) {
if (launch instanceof PDALaunch) {
PDAAdapterFactory.disposeAdapterSet(launch);
}
}
}
} }

View file

@ -184,9 +184,17 @@ public class GdbAdapterFactory
} }
private Map<GdbLaunch, SessionAdapterSet> fLaunchAdapterSets = private static Map<GdbLaunch, SessionAdapterSet> fgLaunchAdapterSets =
Collections.synchronizedMap(new HashMap<GdbLaunch, SessionAdapterSet>()); Collections.synchronizedMap(new HashMap<GdbLaunch, SessionAdapterSet>());
static void disposeAdapterSet(ILaunch launch) {
synchronized(fgLaunchAdapterSets) {
if ( fgLaunchAdapterSets.containsKey(launch) ) {
fgLaunchAdapterSets.remove(launch).dispose();
}
}
}
public GdbAdapterFactory() { public GdbAdapterFactory() {
DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this); DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
} }
@ -207,11 +215,11 @@ public class GdbAdapterFactory
if (session == null) return null; if (session == null) return null;
SessionAdapterSet adapterSet; SessionAdapterSet adapterSet;
synchronized(fLaunchAdapterSets) { synchronized(fgLaunchAdapterSets) {
adapterSet = fLaunchAdapterSets.get(launch); adapterSet = fgLaunchAdapterSets.get(launch);
if (adapterSet == null) { if (adapterSet == null) {
adapterSet = new SessionAdapterSet(launch); adapterSet = new SessionAdapterSet(launch);
fLaunchAdapterSets.put(launch, adapterSet); fgLaunchAdapterSets.put(launch, adapterSet);
} }
} }
@ -236,11 +244,7 @@ public class GdbAdapterFactory
// removed. // removed.
for (ILaunch launch : launches) { for (ILaunch launch : launches) {
if (launch instanceof GdbLaunch) { if (launch instanceof GdbLaunch) {
synchronized(fLaunchAdapterSets) { disposeAdapterSet(launch);
if ( fLaunchAdapterSets.containsKey(launch) ) {
fLaunchAdapterSets.remove(launch).dispose();
}
}
} }
} }
} }

View file

@ -13,7 +13,10 @@ package org.eclipse.dd.gdb.internal.ui;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.dd.gdb.internal.provisional.launching.GdbLaunch;
import org.eclipse.dd.gdb.internal.provisional.launching.LaunchMessages; import org.eclipse.dd.gdb.internal.provisional.launching.LaunchMessages;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPage;
@ -57,11 +60,23 @@ public class GdbUIPlugin extends AbstractUIPlugin {
*/ */
@Override @Override
public void stop(BundleContext context) throws Exception { public void stop(BundleContext context) throws Exception {
disposeAdapterSets();
plugin = null; plugin = null;
super.stop(context); super.stop(context);
fgBundleContext = null; fgBundleContext = null;
} }
/**
* Dispose adapter sets for all launches.
*/
private void disposeAdapterSets() {
for (ILaunch launch : DebugPlugin.getDefault().getLaunchManager().getLaunches()) {
if (launch instanceof GdbLaunch) {
GdbAdapterFactory.disposeAdapterSet(launch);
}
}
}
/** /**
* Returns the shared instance * Returns the shared instance
* *