Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pazderski2020-05-23 00:31:41 +0000
committerPaul Pazderski2020-06-29 21:00:02 +0000
commit4c211278c0d0edf4fb86da00b36eac39edd348d1 (patch)
treeca9d7620053d4d8af8e72fdd8f6985e3aab946da /org.eclipse.debug.ui
parent00d93c9a6e6af649b84604baa0c0866c4d3511e5 (diff)
downloadeclipse.platform.debug-4c211278c0d0edf4fb86da00b36eac39edd348d1.tar.gz
eclipse.platform.debug-4c211278c0d0edf4fb86da00b36eac39edd348d1.tar.xz
eclipse.platform.debug-4c211278c0d0edf4fb86da00b36eac39edd348d1.zip
Bug 404990 - [breakpoints] Delete breakpoint, undo, redo, undo. Gone.
The issue is located in both, the redo and the second undo operation. Delete breakpoint and redo of this operation have the (for this issue relevant) difference that the first set a 'breakpoint deleted' attribute on the marker while the redo does not set/update this attribute. The simple fix is to move the "mark deleted" into the delete marker operation which is executed from an 'initial' delete as well as from a redo. After fixing that a breakpoint is restored but the view does not updated. BreakpointManager does not properly send added notifications. Most of the time it works because an added breakpoint will be registered and the registration will trigger the added notification. However for the add of the second undo the registered attribute is already set, the setRegister(true) which normally triggers the add notification is not executed. Change-Id: Ib509ec9c8116ac4a7bb3f8bcf38dc470e0b90b8b Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
Diffstat (limited to 'org.eclipse.debug.ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/DeleteBreakpointMarkersOperation.java55
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java9
2 files changed, 57 insertions, 7 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/DeleteBreakpointMarkersOperation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/DeleteBreakpointMarkersOperation.java
new file mode 100644
index 000000000..1a1b87589
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/DeleteBreakpointMarkersOperation.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2020 Paul Pazderski and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Paul Pazderski - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.views.breakpoints;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.ui.ide.undo.DeleteMarkersOperation;
+
+/**
+ * Extension of the default undoable delete marker operation to additional
+ * update the 'breakpointIsDeleted' attribute.
+ */
+public class DeleteBreakpointMarkersOperation extends DeleteMarkersOperation {
+
+ /**
+ * Create an undoable operation that can delete the specified markers.
+ *
+ * @param markers the markers to be deleted
+ * @param name the name used to describe the operation that deletes the
+ * markers
+ */
+ public DeleteBreakpointMarkersOperation(IMarker[] markers, String name) {
+ super(markers, name);
+ }
+
+ @Override
+ protected void doExecute(IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws CoreException {
+ IMarker[] markers = getMarkers();
+ if (markers != null) {
+ for (IMarker marker : markers) {
+ marker.setAttribute(DebugPlugin.ATTR_BREAKPOINT_IS_DELETED, true);
+ }
+ }
+
+ super.doExecute(monitor, info);
+ }
+
+ // Note: do not update 'breakpointIsDeleted' on doUndo (i.e. don't set
+ // breakpointIsDeleted=false on undo). It is important that the recreated
+ // breakpoint has breakpointIsDeleted=true to recognize the recreation in later
+ // code.
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java
index e934f3b93..f24c1c9f9 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java
@@ -72,6 +72,7 @@ import org.eclipse.debug.internal.ui.memory.MemoryRenderingManager;
import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupFacility;
import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIUtils;
import org.eclipse.debug.internal.ui.stringsubstitution.SelectedResourceManager;
+import org.eclipse.debug.internal.ui.views.breakpoints.DeleteBreakpointMarkersOperation;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetManager;
import org.eclipse.debug.ui.contexts.IDebugContextListener;
import org.eclipse.debug.ui.contexts.IDebugContextManager;
@@ -101,7 +102,6 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.ide.undo.DeleteMarkersOperation;
import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
@@ -326,11 +326,6 @@ public class DebugUITools {
DebugPlugin.getDefault().getBreakpointManager().removeBreakpoints(breakpoints, !allowUndo);
if (allowUndo) {
-
- for (IMarker marker : markers) {
- marker.setAttribute(DebugPlugin.ATTR_BREAKPOINT_IS_DELETED, true);
- }
-
IAdaptable context= null;
if (shell != null) {
context= new IAdaptable() {
@@ -346,7 +341,7 @@ public class DebugUITools {
}
String operationName= markers.length == 1 ? ActionMessages.DeleteBreakpointOperationName : ActionMessages.DeleteBreakpointsOperationName;
- IUndoableOperation deleteMarkerOperation= new DeleteMarkersOperation(markers, operationName);
+ IUndoableOperation deleteMarkerOperation = new DeleteBreakpointMarkersOperation(markers, operationName);
deleteMarkerOperation.removeContext(WorkspaceUndoUtil.getWorkspaceUndoContext());
deleteMarkerOperation.addContext(DebugUITools.getBreakpointsUndoContext());
IOperationHistory operationHistory= PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();

Back to the top