1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-20 07:25:23 +02:00

Bug 373845 - Terminate should cancel the initialization sequence if it

is still running
This commit is contained in:
Mikhail Khodjaiants 2012-03-16 10:52:26 -04:00
parent 4be0276d23
commit d64f97835e

View file

@ -13,6 +13,8 @@
* Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121) * Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121)
* Mikhail Khodjaiants (Mentor Graphics) - Refactor common code in GDBControl* classes (bug 372795) * Mikhail Khodjaiants (Mentor Graphics) - Refactor common code in GDBControl* classes (bug 372795)
* Marc Khouzam (Ericsson) - Pass errorStream to startCommandProcessing() (Bug 350837) * Marc Khouzam (Ericsson) - Pass errorStream to startCommandProcessing() (Bug 350837)
* Mikhail Khodjaiants (Mentor Graphics) - Terminate should cancel the initialization sequence
* if it is still running (bug 373845)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.service.command; package org.eclipse.cdt.dsf.gdb.service.command;
@ -63,6 +65,7 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler; import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
@ -116,6 +119,8 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
*/ */
private final List<String> fFeatures = new ArrayList<String>(); private final List<String> fFeatures = new ArrayList<String>();
private Sequence fInitializationSequence;
private boolean fTerminated; private boolean fTerminated;
/** /**
@ -192,6 +197,12 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
} }
fTerminated = true; fTerminated = true;
// If the initialization sequence is still running mark it as cancelled,
// to avoid reporting errors to the user, since we are terminating anyway.
if (fInitializationSequence != null) {
fInitializationSequence.getRequestMonitor().cancel();
}
// To fix bug 234467: // To fix bug 234467:
// Interrupt GDB in case the inferior is running. // Interrupt GDB in case the inferior is running.
// That way, the inferior will also be killed when we exit GDB. // That way, the inferior will also be killed when we exit GDB.
@ -290,20 +301,23 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
} catch (CoreException e) {} } catch (CoreException e) {}
// We need a RequestMonitorWithProgress, if we don't have one, we create one. // We need a RequestMonitorWithProgress, if we don't have one, we create one.
RequestMonitorWithProgress progressRm; IProgressMonitor monitor = (rm instanceof RequestMonitorWithProgress) ?
if (rm instanceof RequestMonitorWithProgress) { ((RequestMonitorWithProgress)rm).getProgressMonitor() : new NullProgressMonitor();
progressRm = (RequestMonitorWithProgress)rm; RequestMonitorWithProgress progressRm = new RequestMonitorWithProgress(getExecutor(), monitor) {
} else {
progressRm = new RequestMonitorWithProgress(getExecutor(), new NullProgressMonitor()) {
@Override @Override
protected void handleCompleted() { protected void handleCompleted() {
fInitializationSequence = null;
if (!isCanceled()) {
// Only set the status if the user has not cancelled the operation already.
rm.setStatus(getStatus()); rm.setStatus(getStatus());
}
rm.done(); rm.done();
} }
}; };
}
ImmediateExecutor.getInstance().execute(getCompleteInitializationSequence(attributes, progressRm)); fInitializationSequence = getCompleteInitializationSequence(attributes, progressRm);
ImmediateExecutor.getInstance().execute(fInitializationSequence);
} }
/** /**