changeset 7913:f46e73bcb85b

toplev.cc (main_loop): undo previous change; input.cc (get_debug_input): don't delete global_command here
author John W. Eaton <jwe@octave.org>
date Wed, 09 Jul 2008 18:03:10 -0400
parents 75df1f0b4c9d
children e998e81224b5
files src/ChangeLog src/input.cc src/toplev.cc
diffstat 3 files changed, 25 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Jul 09 16:16:19 2008 -0400
+++ b/src/ChangeLog	Wed Jul 09 18:03:10 2008 -0400
@@ -1,5 +1,8 @@
 2008-07-09  John W. Eaton  <jwe@octave.org>
 
+	* input.cc (get_debug_input): Don't delete global_command here.
+	* toplev.cc (main_loop): Undo previous change.
+
 	* toplev.h (octave_call_stack::instance_ok): Push top scope when
 	creating instance.
 
--- a/src/input.cc	Wed Jul 09 16:16:19 2008 -0400
+++ b/src/input.cc	Wed Jul 09 18:03:10 2008 -0400
@@ -631,24 +631,28 @@
       // This is the same as yyparse in parse.y.
       int retval = octave_parse ();
 
-      tree_statement_list *command = global_command;
+      if (retval == 0 && global_command)
+	{
+	  global_command->eval ();
+
+	  // FIXME -- To avoid a memory leak, global_command should be
+	  // deleted, I think.  But doing that here causes trouble if
+	  // an error occurs while executing a debugging command
+	  // (dbstep, for example). It's not clear to me why that
+	  // happens.
+	  //
+	  // delete global_command;
+	  //
+	  // global_command = 0;
+
+	  if (octave_completion_matches_called)
+	    octave_completion_matches_called = false;	    
+	}
 
       // Restore previous value of global_command.
       unwind_protect::run ();
 
-      if (retval == 0 && command)
-	{
-	  command->eval ();
-
-	  delete command;
-
-	  command = 0;
-
-	  OCTAVE_QUIT;
-
-	  if (octave_completion_matches_called)
-	    octave_completion_matches_called = false;	    
-	}
+      OCTAVE_QUIT;
     }
 
   unwind_protect::run_frame ("get_debug_input");
--- a/src/toplev.cc	Wed Jul 09 16:16:19 2008 -0400
+++ b/src/toplev.cc	Wed Jul 09 18:03:10 2008 -0400
@@ -543,8 +543,6 @@
 
   octave_initialized = true;
 
-  unwind_protect::begin_frame ("main_loop");
-
   // The big loop.
 
   int retval = 0;
@@ -558,26 +556,18 @@
 
 	  reset_parser ();
 
-	  // Save current value of global_command.
-	  unwind_protect_ptr (global_command);
-
 	  // This is the same as yyparse in parse.y.
 	  retval = octave_parse ();
 
-	  tree_statement_list *command = global_command;
-
-	  // Restore previous value of global_command.
-	  unwind_protect::run ();
-
 	  if (retval == 0)
 	    {
-	      if (command)
+	      if (global_command)
 		{
-		  command->eval ();
+		  global_command->eval ();
 
-		  delete command;
+		  delete global_command;
 
-		  command = 0;
+		  global_command = 0;
 
 		  OCTAVE_QUIT;
 
@@ -632,8 +622,6 @@
     }
   while (retval == 0);
 
-  unwind_protect::run_frame ("main_loop");
-
   return retval;
 }