Mercurial > octave
changeset 24001:8e4abfaadd97
attempt better cleanup of Octave interpreter thread in GUI
* main-window.cc (main_window::main_window): Connect m_interpreter
octave_finished_signal to m_main_thread quit slot. Connect
m_main_thread finished signal to m_main_thread deleteLater slot.
(main_window::~main_window): Don't attempt to terminate or delete
m_main_thread.
(main_window::handle_octave_finished): Don't terminate m_main_thread.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 04 Sep 2017 13:55:14 -0400 |
parents | d9ef3699b614 |
children | 94cbb6dd7b21 |
files | libgui/src/main-window.cc |
diffstat | 1 files changed, 10 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/main-window.cc Mon Sep 04 10:51:43 2017 +0200 +++ b/libgui/src/main-window.cc Mon Sep 04 13:55:14 2017 -0400 @@ -217,6 +217,12 @@ connect (m_interpreter, SIGNAL (octave_finished_signal (int)), this, SLOT (handle_octave_finished (int))); + connect (m_interpreter, SIGNAL (octave_finished_signal (int)), + m_main_thread, SLOT (quit ())); + + connect (m_main_thread, SIGNAL (finished ()), + m_main_thread, SLOT (deleteLater ())); + m_interpreter->moveToThread (m_main_thread); m_main_thread->start (); @@ -224,6 +230,10 @@ main_window::~main_window (void) { + // Note that we don't delete m_main_thread here. That is handled by + // deleteLater slot that is called when the m_main_thread issues a + // finished signal. + // Destroy the terminal first so that STDERR stream is redirected back // to its original pipe to capture error messages at exit. @@ -239,17 +249,6 @@ delete variable_editor_window; delete m_interpreter; - // We are supposed to arrive here after the main thread is done, but - // if that doesn't happen for some reason, then terminate and wait - // before deleting it. - if (! m_main_thread->isFinished ()) - { - m_main_thread->terminate (); - // FIXME: should there be a limit on how long we wait? - m_main_thread->wait (); - } - delete m_main_thread; - if (find_files_dlg) { delete find_files_dlg; @@ -1911,12 +1910,6 @@ void main_window::handle_octave_finished (int exit_status) { - // The main thread is done, so we can terminate it and wait for it to - // finish. - m_main_thread->terminate (); - // FIXME: should there be a limit on how long we wait? - m_main_thread->wait (); - qApp->exit (exit_status); }