Mercurial > octave
changeset 28619:cd7bbca7eae3
maint: merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 14 Aug 2020 00:50:03 -0400 |
parents | 5da49e37a6c9 (current diff) af302efce502 (diff) |
children | 174dc4519e73 |
files | libinterp/corefcn/interpreter.cc libinterp/parse-tree/pt-eval.cc |
diffstat | 3 files changed, 45 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/interpreter.cc Thu Aug 13 23:57:07 2020 +0900 +++ b/libinterp/corefcn/interpreter.cc Fri Aug 14 00:50:03 2020 -0400 @@ -854,22 +854,43 @@ void interpreter::shutdown (void) { + OCTAVE_SAFE_CALL (feval, ("close", ovl ("all"), 0)); + // If we are attached to a GUI, process pending events and // disable the link. - m_event_manager.process_events (true); - m_event_manager.disable (); + OCTAVE_SAFE_CALL (m_event_manager.process_events, (true)); + OCTAVE_SAFE_CALL (m_event_manager.disable, ()); OCTAVE_SAFE_CALL (m_input_system.clear_input_event_hooks, ()); // Any atexit functions added after this function call won't be - // executed. + // executed. Each atexit function is executed with + // OCTAVE_SAFE_CALL, so we don't need that here. execute_atexit_fcns (); + // Clear all functions and variables. + + OCTAVE_SAFE_CALL (clear_all, (true)); + + // We may still have some figures. Close them. + + OCTAVE_SAFE_CALL (feval, ("close", ovl ("all"), 0)); + + // What is supposed to happen if a figure has a closerequestfcn or + // deletefcn callback registered that creates other figures or + // variables? What if those variables are classdef objects with + // destructors that can create figures? The possibilities are + // endless. At some point, we have to give up and force execution + // to end. + + OCTAVE_SAFE_CALL (clear_all, (true)); + // Do this explicitly so that destructors for mex file objects // are called, so that functions registered with mexAtExit are // called. + OCTAVE_SAFE_CALL (m_symbol_table.clear_mex_functions, ()); OCTAVE_SAFE_CALL (command_editor::restore_terminal_state, ()); @@ -879,14 +900,15 @@ if (! command_history::ignoring_entries ()) OCTAVE_SAFE_CALL (command_history::clean_up_and_save, ()); - OCTAVE_SAFE_CALL (m_gh_manager->close_all_figures, ()); - - m_gtk_manager.unload_all_toolkits (); - // FIXME: May still need something like this to ensure that // destructors for class objects will run properly. Should that be // done earlier? Before or after atexit functions are executed? - m_symbol_table.cleanup (); + // What will happen if the destructor for an obect attempts to + // display a figure? + + OCTAVE_SAFE_CALL (m_symbol_table.cleanup, ()); + + OCTAVE_SAFE_CALL (m_gtk_manager.unload_all_toolkits, ()); OCTAVE_SAFE_CALL (sysdep_cleanup, ());
--- a/libinterp/parse-tree/pt-eval.cc Thu Aug 13 23:57:07 2020 +0900 +++ b/libinterp/parse-tree/pt-eval.cc Fri Aug 14 00:50:03 2020 -0400 @@ -1669,11 +1669,14 @@ int index_position = tw.index_position (); int num_indices = tw.num_indices (); - // Return invalid index value instead of throwing an error so that we - // will see an error about the object that is indexed rather than - // "end" being used incorrectly. + // If indexed_object is nullptr, then this use of 'end' is either + // appearing in a function call argument list or in an attempt to + // index an undefined symbol. There seems to be no reasonable way to + // provide a better error message. So just fail with an invalid use + // message. See bug #58830. + if (! indexed_object) - return ovl (octave_NaN); + error ("invalid use of 'end': may only be used to index existing value"); if (indexed_object->isobject ()) { @@ -1723,8 +1726,9 @@ } /* -%!test <*33637> -%! fail ("__undef_sym__ (end)", "'__undef_sym__' undefined"); +%!test <*58830> +%! fail ("__undef_sym__ (end)", +%! "invalid use of 'end': may only be used to index existing value"); */ namespace octave
--- a/libinterp/parse-tree/pt-idx.cc Thu Aug 13 23:57:07 2020 +0900 +++ b/libinterp/parse-tree/pt-idx.cc Fri Aug 14 00:50:03 2020 -0400 @@ -502,22 +502,17 @@ tw.set_lvalue_list (nullptr); string_vector anm = *p_arg_nm; + first_args = tw.convert_to_const_vector (al); + first_args.stash_name_tags (anm); } - symbol_record sym = id->symbol (); - - octave_value val = tw.varval (sym); + interpreter& interp = tw.get_interpreter (); - if (val.is_undefined ()) - { - interpreter& interp = tw.get_interpreter (); + symbol_table& symtab = interp.get_symbol_table (); - symbol_table& symtab = interp.get_symbol_table (); - - val = symtab.find_function (sym.name (), first_args); - } + octave_value val = symtab.find_function (nm, first_args); octave_function *fcn = nullptr;