From 8bc24567aff42a0e7ec416384d45b3d71ba3f071 Mon Sep 17 00:00:00 2001 From: John Cortell Date: Thu, 14 Feb 2008 22:33:38 +0000 Subject: [PATCH] Adjustment to 218194. There was a concern that there might be IBreakpointListeners out there that are interested in the INSTALL_COUNT attribute, since that attribute was defined in a public interface. This new solution is a hybrid between the original logic and the initial fix to 218194. We don't use the INSTALL_COUNT attribute to maintain the install count, but we update it when it changes. I've updated the documentation for the attribute. --- .../cdt/debug/core/model/ICBreakpoint.java | 21 ++++++++++---- .../core/breakpoints/CBreakpoint.java | 28 ++++++++----------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpoint.java index 044a1b1e425..c95bdba2afc 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpoint.java @@ -26,13 +26,22 @@ import org.eclipse.debug.core.model.IBreakpoint; public interface ICBreakpoint extends IBreakpoint { /** - * Breakpoint attribute that we use merely as a way to force the marker to - * refresh. When a CDT internal, but not persisted, state of the breakpoint - * changes in a way that calls for the marker to refresh, we simply store a - * timestamp (Long.toString(Date.getTime())) into this setting. The platform - * responds to all marker attrib changes with a marker refresh. + * Breakpoint attribute storing the number of debug targets a breakpoint is + * installed in (value + * "org.eclipse.cdt.debug.core.installCount"). This + * attribute is an int. + * + * Note: this attribute is used only for notifying listeners + * (IBreakpointListener) of a change in the install count. The attribute is + * not used by the CDT breakpoint object to manage the install count, since + * it is a transient property of a breakpoint, and marker attributes are + * persisted. In other words, it's conceivable that upon breakpoint manager + * initialization, a breakpoint is reconstructed with this attribute being + * >0. That doesn't mean the breakpoint is installed (at workbench launch + * time, there are no installed breakpoints). At that time, the attribute + * means absolutely nothing. */ - public static final String FORCE_UPDATE = "org.eclipse.cdt.debug.core.forceupdate"; //$NON-NLS-1$ + public static final String INSTALL_COUNT = "org.eclipse.cdt.debug.core.installCount"; //$NON-NLS-1$ /** * Breakpoint attribute storing the conditional expression associated with diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpoint.java index 663dce41f3b..eda3edec5ea 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpoint.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.debug.internal.core.breakpoints; import java.text.MessageFormat; import java.util.ArrayList; -import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -50,7 +49,9 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, ID private Map fExtensions = new HashMap(1); /** - * The number of debug targets the breakpoint is installed in. + * The number of debug targets the breakpoint is installed in. We don't use + * the INSTALL_COUNT attribute to manage this property (see bugzilla 218194) + * */ private int fInstallCount = 0; @@ -227,11 +228,9 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, ID public synchronized int incrementInstallCount() throws CoreException { ++fInstallCount; - // handle the crossing into the installed state; we decorate - // an installed marker with a blue checkmark - if (fInstallCount == 1) { - setAttribute(FORCE_UPDATE, Long.toString((new Date()).getTime())); // force a refresh of the marker through a dummy attribute - } + // cause the marker to update; will ultimately result in a blue checkmark + // when install count > 0 + setAttribute(INSTALL_COUNT, fInstallCount); return fInstallCount; } @@ -250,11 +249,9 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, ID public synchronized int decrementInstallCount() throws CoreException { fInstallCount--; - // handle the crossing into the uninstalled state; we decorate - // an installed marker with a blue checkmark - if (fInstallCount == 0) { - setAttribute(FORCE_UPDATE, Long.toString((new Date()).getTime())); // force a refresh of the marker through a dummy attribute - } + // cause the marker to update; will ultimately remove blue checkmark + // when install count == 0 + setAttribute(INSTALL_COUNT, fInstallCount); return fInstallCount; } @@ -263,10 +260,9 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint, ID * @see org.eclipse.cdt.debug.core.model.ICBreakpoint#resetInstallCount() */ public synchronized void resetInstallCount() throws CoreException { - int previous = fInstallCount; - fInstallCount = 0; - if (previous != 0) { - setAttribute(FORCE_UPDATE, Long.toString((new Date()).getTime())); // force a refresh of the marker through a dummy attribute + if (fInstallCount != 0) { + fInstallCount = 0; + setAttribute(INSTALL_COUNT, fInstallCount); } }