User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2b) Gecko/20021002
Hello,
I have an action where I want to disable all the currently enabled
breakpoints. I can successfully do this by calling
IBreakpoint.setEnabled( false ).
This code does what I want:
final IBreakpointManager breakpointManager=
DebugPlugin.getDefault().getBreakpointManager();
final IBreakpoint[] breakpoints= breakpointManager.getBreakpoints();
for ( int i = 0; i < breakpoints.length; i++ ) {
if ( breakpoints[i].isEnabled()) {
breakpoints[i].setEnabled(false);
}
}
However, it is slow. Each setEnabled() call creates its own
IWorkspaceRunnable and runs it. If you have a lot of breakpoints
(25-30), the slowdown is noticeable. So to speed it up, I thought that
I could do exactly what the setEnabled() call does, but wrap my entire
loop in just one IWorkspaceRunnable. Basically, instead of the
setEnabled() call, I just get the breakpoint's IMarker and set the
appropriate attribute to false (which is exactly what happens inside
setEnabled).
Here's the code:
IWorkspace workspace= ResourcesPlugin.getWorkspace();
IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
for ( int i = 0; i < breakpoints.length; i++ ) {
if ( breakpoints[i].isEnabled()) {
breakpoints[i].getMarker().setAttribute(
IBreakpoint.ENABLED,
Boolean.FALSE); }
} }
};
workspace.run(runnable, null);
Now at first this SEEMS to work. All of the breakpoints in the
breakpoints view become visually disabled. However, when debugging
code, the debugger still stops at all of the breakpoints, even though
they appear disabled in the breakpoints view and the editor margins.
Why is this? Why does it work correctly when I call
IBreakpont.setEnabled() but not when I call the same exact code that is
inside setEnabled() myself? Is there some notification that gets sent
normally that I am not sending? I can't figure out what the difference
is, and it's starting to bamboozle me! :) If anyone has an idea on
what could be going on, I'd appreciate the help.
(I'm trying this code in the eclipse M5 driver.)
Thanks
Tom