diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java index 13e267fa90b..e7ee89f9391 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 QNX Software Systems and others. + * Copyright (c) 2004, 2009 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -155,16 +155,16 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart */ protected void updateVariables() throws DebugException { List locals = getAllCDIVariableObjects(); - int index = 0; - while( index < fVariables.size() ) { - ICDIVariableDescriptor varObject = findVariable( locals, (CVariable)fVariables.get( index ) ); - if ( varObject != null ) { - locals.remove( varObject ); - index++; - } + Iterator it = fVariables.iterator(); + while (it.hasNext()) { + CVariable var = it.next(); + ICDIVariableDescriptor varObject = findVariable(locals, var); + if (varObject != null && !var.isDisposed()) + locals.remove(varObject); else { - // remove variable - fVariables.remove( index ); + // ensure variable is unregistered from event listener + var.dispose(); + it.remove(); } } // add any new locals diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java index 41d1a6e7908..08782f074e8 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 QNX Software Systems and others. + * Copyright (c) 2004, 2009 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,6 +16,7 @@ import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDebugConstants; import org.eclipse.cdt.debug.core.cdi.event.ICDIChangedEvent; +import org.eclipse.cdt.debug.core.cdi.event.ICDIDestroyedEvent; import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent; import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener; import org.eclipse.cdt.debug.core.cdi.event.ICDIMemoryChangedEvent; @@ -507,6 +508,11 @@ public abstract class CVariable extends AbstractCVariable implements ICDIEventLi else if ( event instanceof ICDIResumedEvent ) { handleResumedEvent( (ICDIResumedEvent)event ); } + else if (event instanceof ICDIDestroyedEvent + && iv.getCdiObject() == source) { + dispose(); + fireChangeEvent(DebugEvent.STATE); + } } } }