? duplicate_abort.patch
Index: emctask.cc
===================================================================
RCS file: /cvs/emc2/src/emc/task/emctask.cc,v
retrieving revision 1.36
diff -U3 -r1.36 emctask.cc
--- emctask.cc	1 Mar 2009 00:50:33 -0000	1.36
+++ emctask.cc	26 May 2009 10:45:20 -0000
@@ -114,6 +114,17 @@
 {
     emcMotionAbort();
 
+    // without emcTaskPlanClose(), a new run command resumes at
+    // aborted line-- feature that may be considered later
+    {
+	int was_open = taskplanopen;
+	emcTaskPlanClose();
+	if (EMC_DEBUG & EMC_DEBUG_INTERP && was_open) {
+	    rcs_print("emcTaskPlanClose() called at %s:%d\n", __FILE__,
+		      __LINE__);
+	}
+    }
+
     // clear out the pending command
     emcTaskCommand = 0;
     interp_list.clear();
@@ -123,6 +134,7 @@
     emcStatus->task.execState = EMC_TASK_EXEC_DONE;
     emcStatus->task.task_paused = 0;
     emcStatus->task.motionLine = 0;
+    emcStatus->task.currentLine = 0;
     emcStatus->task.readLine = 0;
     stepping = 0;
     steppingWait = 0;
@@ -131,17 +143,6 @@
     EMC_TASK_PLAN_SYNCH taskPlanSynchCmd;
     emcTaskQueueCommand(&taskPlanSynchCmd);
 
-    // without emcTaskPlanClose(), a new run command resumes at
-    // aborted line-- feature that may be considered later
-    {
-	int was_open = taskplanopen;
-	emcTaskPlanClose();
-	if (EMC_DEBUG & EMC_DEBUG_INTERP && was_open) {
-	    rcs_print("emcTaskPlanClose() called at %s:%d\n", __FILE__,
-		      __LINE__);
-	}
-    }
-
     return 0;
 }
 
Index: emctaskmain.cc
===================================================================
RCS file: /cvs/emc2/src/emc/task/emctaskmain.cc,v
retrieving revision 1.137
diff -U3 -r1.137 emctaskmain.cc
--- emctaskmain.cc	26 May 2009 08:31:09 -0000	1.137
+++ emctaskmain.cc	26 May 2009 10:45:26 -0000
@@ -1905,38 +1905,8 @@
 	    if (mode_msg->mode == EMC_TASK_MODE_MANUAL &&
 		emcStatus->task.mode != EMC_TASK_MODE_MANUAL) {
 		// leaving auto or mdi mode for manual
-
-		/*! \todo FIXME-- duplicate code for abort,
-	        also near end of main, when aborting on subordinate errors,
-	        and in emcTaskExecute() */
-
 		// abort motion
 		emcTaskAbort();
-
-		// without emcTaskPlanClose(), a new run command resumes at
-		// aborted line-- feature that may be considered later
-		{
-		    int was_open = taskplanopen;
-		    emcTaskPlanClose();
-		    if (EMC_DEBUG & EMC_DEBUG_INTERP && was_open) {
-			rcs_print("emcTaskPlanClose() called at %s:%d\n",
-			      __FILE__, __LINE__);
-		    }
-		}
-
-		// clear out the pending command
-		emcTaskCommand = 0;
-		interp_list.clear();
-                emcStatus->task.currentLine = 0;
-
-		// clear out the interpreter state
-		emcStatus->task.interpState = EMC_TASK_INTERP_IDLE;
-		emcStatus->task.execState = EMC_TASK_EXEC_DONE;
-		stepping = 0;
-		steppingWait = 0;
-
-		// now queue up command to resynch interpreter
-		emcTaskQueueCommand(&taskPlanSynchCmd);
 		retval = 0;
 	    }
 	    retval = emcTaskSetMode(mode_msg->mode);
@@ -2258,41 +2228,10 @@
 
     switch (emcStatus->task.execState) {
     case EMC_TASK_EXEC_ERROR:
-
-	/*! \todo FIXME-- duplicate code for abort,
-	   also near end of main, when aborting on subordinate errors,
-	   and in emcTaskIssueCommand() */
-
 	// abort everything
 	emcTaskAbort();
         emcIoAbort();
         emcSpindleAbort();
-
-	// without emcTaskPlanClose(), a new run command resumes at
-	// aborted line-- feature that may be considered later
-	{
-	    int was_open = taskplanopen;
-	    emcTaskPlanClose();
-	    if (EMC_DEBUG & EMC_DEBUG_INTERP && was_open) {
-		rcs_print("emcTaskPlanClose() called at %s:%d\n", __FILE__,
-			  __LINE__);
-	    }
-	}
-
-	// clear out pending command
-	emcTaskCommand = 0;
-	interp_list.clear();
-        emcStatus->task.currentLine = 0;
-
-	// clear out the interpreter state
-	emcStatus->task.interpState = EMC_TASK_INTERP_IDLE;
-	emcStatus->task.execState = EMC_TASK_EXEC_DONE;
-	stepping = 0;
-	steppingWait = 0;
-
-	// now queue up command to resynch interpreter
-	emcTaskQueueCommand(&taskPlanSynchCmd);
-
 	retval = -1;
 	break;
 
@@ -3046,39 +2985,10 @@
 	// check for subordinate errors, and halt task if so
 	if (emcStatus->motion.status == RCS_ERROR ||
 	    emcStatus->io.status == RCS_ERROR) {
-
-	    /*! \todo FIXME-- duplicate code for abort,
-	       also in emcTaskExecute()
-	       and in emcTaskIssueCommand() */
-
             // abort everything
             emcTaskAbort();
             emcIoAbort();
             emcSpindleAbort();
-            // without emcTaskPlanClose(), a new run command resumes at
-            // aborted line-- feature that may be considered later
-            {
-                int was_open = taskplanopen;
-                emcTaskPlanClose();
-                if (EMC_DEBUG & EMC_DEBUG_INTERP && was_open) {
-                    rcs_print("emcTaskPlanClose() called at %s:%d\n",
-                              __FILE__, __LINE__);
-                }
-            }
-            
-            // clear out the pending command
-            emcTaskCommand = 0;
-            interp_list.clear();
-            emcStatus->task.currentLine = 0;
-            
-            // clear out the interpreter state
-            emcStatus->task.interpState = EMC_TASK_INTERP_IDLE;
-            emcStatus->task.execState = EMC_TASK_EXEC_DONE;
-            stepping = 0;
-            steppingWait = 0;
-
-            // now queue up command to resynch interpreter
-            emcTaskQueueCommand(&taskPlanSynchCmd);
 	}
 
 	// update task-specific status
