changeset 20769:58e79b0078e4

handle exceptions when discarding error messages (bug #46534) * oct-parse.in.yy (octave_base_parser::finish_colon_expression, octave_base_parser::finish_array_list): Catch and recover from exception that may happen when error messages are being discarded. * graphics.cc (base_graphics_object::remove_all_listeners): Likewise. * variables.cc (generate_struct_completions): Likewise.
author John W. Eaton <jwe@octave.org>
date Fri, 27 Nov 2015 11:14:46 -0500
parents 7655b399abff
children 826a4771718b
files libinterp/corefcn/graphics.cc libinterp/corefcn/variables.cc libinterp/parse-tree/oct-parse.in.yy
diffstat 3 files changed, 72 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc	Fri Nov 27 10:46:17 2015 -0500
+++ b/libinterp/corefcn/graphics.cc	Fri Nov 27 11:14:46 2015 -0500
@@ -3228,10 +3228,17 @@
       Vdebug_on_error = false;
       Vdebug_on_warning = false;
 
-      property p = get_properties ().get_property (pa->first);
-
-      if (p.ok ())
-        p.delete_listener ();
+      try
+        {
+          property p = get_properties ().get_property (pa->first);
+
+          if (p.ok ())
+            p.delete_listener ();
+        }
+      catch (const octave_execution_exception&)
+        {
+          recover_from_exception ();
+        }
     }
 }
 
--- a/libinterp/corefcn/variables.cc	Fri Nov 27 10:46:17 2015 -0500
+++ b/libinterp/corefcn/variables.cc	Fri Nov 27 11:14:46 2015 -0500
@@ -268,13 +268,20 @@
           discard_error_messages = true;
           discard_warning_messages = true;
 
-          octave_value tmp = eval_string (prefix, true, parse_status);
-
-          frame.run ();
-
-          if (tmp.is_defined ()
-              && (tmp.is_map () || tmp.is_java () || tmp.is_classdef_object ()))
-            names = tmp.map_keys ();
+          try
+            {
+              octave_value tmp = eval_string (prefix, true, parse_status);
+
+              frame.run ();
+
+              if (tmp.is_defined ()
+                  && (tmp.is_map () || tmp.is_java () || tmp.is_classdef_object ()))
+                names = tmp.map_keys ();
+            }
+          catch (const octave_execution_exception&)
+            {
+              recover_from_exception ();
+            }
         }
     }
 
--- a/libinterp/parse-tree/oct-parse.in.yy	Fri Nov 27 10:46:17 2015 -0500
+++ b/libinterp/parse-tree/oct-parse.in.yy	Fri Nov 27 11:14:46 2015 -0500
@@ -2263,22 +2263,29 @@
           if (base->is_constant () && limit->is_constant ()
               && (! incr || (incr && incr->is_constant ())))
             {
-              octave_value tmp = e->rvalue1 ();
-
-              tree_constant *tc_retval
-                = new tree_constant (tmp, base->line (), base->column ());
-
-              std::ostringstream buf;
-
-              tree_print_code tpc (buf);
-
-              e->accept (tpc);
-
-              tc_retval->stash_original_text (buf.str ());
-
-              delete e;
-
-              retval = tc_retval;
+              try
+                {
+                  octave_value tmp = e->rvalue1 ();
+
+                  tree_constant *tc_retval
+                    = new tree_constant (tmp, base->line (), base->column ());
+
+                  std::ostringstream buf;
+
+                  tree_print_code tpc (buf);
+
+                  e->accept (tpc);
+
+                  tc_retval->stash_original_text (buf.str ());
+
+                  delete e;
+
+                  retval = tc_retval;
+                }
+              catch (const octave_execution_exception&)
+                {
+                  recover_from_exception ();
+                }
             }
         }
       else
@@ -3801,23 +3808,30 @@
 
   if (array_list->all_elements_are_constant ())
     {
-      octave_value tmp = array_list->rvalue1 ();
-
-      tree_constant *tc_retval
-        = new tree_constant (tmp, array_list->line (),
-                             array_list->column ());
-
-      std::ostringstream buf;
-
-      tree_print_code tpc (buf);
-
-      array_list->accept (tpc);
-
-      tc_retval->stash_original_text (buf.str ());
-
-      delete array_list;
-
-      retval = tc_retval;
+      try
+        {
+          octave_value tmp = array_list->rvalue1 ();
+
+          tree_constant *tc_retval
+            = new tree_constant (tmp, array_list->line (),
+                                 array_list->column ());
+
+          std::ostringstream buf;
+
+          tree_print_code tpc (buf);
+
+          array_list->accept (tpc);
+
+          tc_retval->stash_original_text (buf.str ());
+
+          delete array_list;
+
+          retval = tc_retval;
+        }
+      catch (const octave_execution_exception&)
+        {
+          recover_from_exception ();
+        }
     }
 
   return retval;