changeset 28622:d075c2f26d1d stable

reorder shutdown steps (bug #57591) * interpreter.cc (interpreter::shutdown): When initially clearing symbols, don't force them to be cleared. Do force symbols to be cleared after all graphics toolkits have been unloaded.
author John W. Eaton <jwe@octave.org>
date Sat, 15 Aug 2020 23:40:00 -0400
parents 45a9dcee45db
children 7bdd127d77e5 60d2b3d903d4
files libinterp/corefcn/interpreter.cc
diffstat 1 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/interpreter.cc	Fri Aug 14 13:37:07 2020 -0700
+++ b/libinterp/corefcn/interpreter.cc	Sat Aug 15 23:40:00 2020 -0400
@@ -863,7 +863,11 @@
 
     // Clear all functions and variables.
 
-    OCTAVE_SAFE_CALL (clear_all, (true));
+    // Note that we don't force symbols to be cleared, so we will
+    // respect mlock at this point.  Later, we'll force all variables
+    // and functions to be cleared.
+
+    OCTAVE_SAFE_CALL (clear_all, ());
 
     // We may still have some figures.  Close them.
 
@@ -876,7 +880,11 @@
     // endless.  At some point, we have to give up and force execution
     // to end.
 
-    OCTAVE_SAFE_CALL (clear_all, (true));
+    // Note that we again don't force symbols to be cleared, so we
+    // continue to respect mlock here.  Later, we'll force all variables
+    // and functions to be cleared.
+
+    OCTAVE_SAFE_CALL (clear_all, ());
 
     // Do this explicitly so that destructors for mex file objects
     // are called, so that functions registered with mexAtExit are
@@ -891,6 +899,13 @@
     if (! command_history::ignoring_entries ())
       OCTAVE_SAFE_CALL (command_history::clean_up_and_save, ());
 
+    OCTAVE_SAFE_CALL (m_gtk_manager.unload_all_toolkits, ());
+
+    // Now that the graphics toolkits have been unloaded, force all
+    // symbols to be cleared.
+
+    OCTAVE_SAFE_CALL (clear_all, (true));
+
     // 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?
@@ -899,8 +914,6 @@
 
     OCTAVE_SAFE_CALL (m_symbol_table.cleanup, ());
 
-    OCTAVE_SAFE_CALL (m_gtk_manager.unload_all_toolkits, ());
-
     OCTAVE_SAFE_CALL (sysdep_cleanup, ());
 
     OCTAVE_SAFE_CALL (flush_stdout, ());