Mercurial > octave
changeset 21857:0331d3e832e3
Catch spurious errors thrown by the parser when executing callbacks (bug #48175)
* graphics.cc (gh_manager::do_execute_callback): Catch spurious
octave_execution_exceptions when executing user callbacks. Indicate that the
error message came from a callback and restore the previous error state.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Thu, 09 Jun 2016 10:57:22 -0700 |
parents | c9c5340d4758 |
children | 25b117822bfd |
files | libinterp/corefcn/graphics.cc |
diffstat | 1 files changed, 25 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc Fri Jun 10 17:06:16 2016 -0700 +++ b/libinterp/corefcn/graphics.cc Thu Jun 09 10:57:22 2016 -0700 @@ -9516,6 +9516,9 @@ xset_gcbo (h); } + // Get a copy of the global last error so it can be restored. + octave_value_list result = feval ("lasterror", ovl (), 1); + // Copy CB because "function_value" method is non-const. octave_value cb = cb_arg; @@ -9527,7 +9530,17 @@ int status; std::string s = cb.string_value (); - eval_string (s, false, status, 0); + try + { + eval_string (s, false, status, 0); + } + catch (octave_execution_exception&) + { + std::cerr << "execution error in graphics callback function" + << std::endl; + feval ("lasterror", result); + recover_from_exception (); + } } else if (cb.is_cell () && cb.length () > 0 && (cb.rows () == 1 || cb.columns () == 1) @@ -9549,7 +9562,17 @@ } if (fcn) - feval (fcn, args); + try + { + feval (fcn, args); + } + catch (octave_execution_exception&) + { + std::cerr << "execution error in graphics callback function" + << std::endl; + feval ("lasterror", result); + recover_from_exception (); + } if (Vdrawnow_requested) {