# HG changeset patch # User John W. Eaton # Date 1618950010 14400 # Node ID 841ca998730286ca11a36db1fbbadd9d1d445cb2 # Parent 6dfc06f55cd25c1334f5953824306910ec60acfc perform shutdown actions in interpreter destructor (bug #60334) * interpreter.cc (interpreter::~interpreter): Call shutdown. (interpreter::shutdown): Return immediately if m_initialized is false and set m_initialized to false to prevent shutdown from being executed recursively. * embedded.cc (main): Don't call shutdown for interpreter object. * octave.cc (cli_application::execute): Likewise. diff -r 6dfc06f55cd2 -r 841ca9987302 examples/code/embedded.cc --- a/examples/code/embedded.cc Wed Apr 14 15:03:09 2021 +0200 +++ b/examples/code/embedded.cc Tue Apr 20 16:20:10 2021 -0400 @@ -76,8 +76,5 @@ std::cerr << "error encountered in Octave evaluator!" << std::endl; } - // Shutdown the interpreter which cleanly releases all memory. - interpreter.shutdown (); - return 0; } diff -r 6dfc06f55cd2 -r 841ca9987302 libinterp/corefcn/interpreter.cc --- a/libinterp/corefcn/interpreter.cc Wed Apr 14 15:03:09 2021 +0200 +++ b/libinterp/corefcn/interpreter.cc Tue Apr 20 16:20:10 2021 -0400 @@ -635,6 +635,8 @@ interpreter::~interpreter (void) { + shutdown (); + delete m_gh_manager; } @@ -845,6 +847,13 @@ void interpreter::shutdown (void) { + // Attempt to prevent more than one call to shutdown. + + if (! m_initialized) + return; + + m_initialized = false; + OCTAVE_SAFE_CALL (feval, ("close", ovl ("all"), 0)); // If we are attached to a GUI, process pending events and diff -r 6dfc06f55cd2 -r 841ca9987302 libinterp/octave.cc --- a/libinterp/octave.cc Wed Apr 14 15:03:09 2021 +0200 +++ b/libinterp/octave.cc Tue Apr 20 16:20:10 2021 -0400 @@ -378,8 +378,6 @@ int status = interp.execute (); - interp.shutdown (); - return status; } }