Mercurial > octave
diff libgui/src/interpreter-qobject.cc @ 27218:a044202208af
more refactoring of GUI classes that manage the interpreter
* interpreter-qobject.h, interpreter-qobject.cc
(interpreter_qobject::m_app_context): Delete.
(interpreter_qobject::m_octave_qobject,
interpreter_qobject::m_qt_link): New data members.
(interpreter_qobject::interpreter_qobject): Accept reference to
base_qobject as argument instead of qt_application object.
Make octave_qt_link connections here.
(interpreter_qobject::confirm_shutdown, interpreter_qobject::qt_link):
New functions.
* main-window.h, main-window.cc (main_window::m_octave_qapp,
main_window::m_octave_qt_link): Delete data members.
(main_window::m_octave_qobj): New data membeer.
(main_window::main_window): Don't pass pointer to octave_qt_link as
separate argument. In other member functions, get QApplication and
octave_qt_link objects from m_octave_qobj as needed.
* octave-qobject.h, octave-qobject.cc
(base_qobject::m_octave_qt_link): Delete.
(base_qobject::base_qobject): Don't make connections to octave_qt_lnk
signals here.
(base_qobject::confirm_shutdown_octave_internal): Delete.
(base_qobject::confirm_shutdown_octave): Call
interpreter_qobject::confirm_shutdown instead of
confirm_shutdown_octave_internal.
(gui_qobject::confirm_shutdown_octave): Likewise.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 28 Jun 2019 14:42:44 -0400 |
parents | b8c0d5ad024f |
children | 5ac60319575b |
line wrap: on
line diff
--- a/libgui/src/interpreter-qobject.cc Thu Jun 27 13:27:22 2019 -0400 +++ b/libgui/src/interpreter-qobject.cc Fri Jun 28 14:42:44 2019 -0400 @@ -26,6 +26,8 @@ #endif #include "interpreter-qobject.h" +#include "octave-qobject.h" +#include "octave-qt-link.h" #include "qt-application.h" #include "input.h" @@ -33,15 +35,28 @@ namespace octave { - interpreter_qobject::interpreter_qobject (qt_application& app_context) - : QObject (), m_app_context (app_context) - { } + interpreter_qobject::interpreter_qobject (base_qobject *oct_qobj) + : QObject (), m_octave_qobject (oct_qobj), + m_qt_link (new octave_qt_link ()) + { + octave_link::connect_link (m_qt_link); + + connect (m_qt_link, SIGNAL (confirm_shutdown_signal (void)), + m_octave_qobject, SLOT (confirm_shutdown_octave (void))); + + connect (m_qt_link, + SIGNAL (copy_image_to_clipboard_signal (const QString&, bool)), + m_octave_qobject, + SLOT (copy_image_to_clipboard (const QString&, bool))); + } void interpreter_qobject::execute (void) { - // The application context owns the interpreter. + // The Octave application context owns the interpreter. - interpreter& interp = m_app_context.create_interpreter (); + qt_application& app_context = m_octave_qobject->app_context (); + + interpreter& interp = app_context.create_interpreter (); int exit_status = 0; @@ -51,7 +66,7 @@ interp.initialize (); - if (m_app_context.start_gui_p ()) + if (app_context.start_gui_p ()) { input_system& input_sys = interp.get_input_system (); @@ -79,8 +94,21 @@ // Whether or not initialization succeeds we need to clean up the // interpreter once we are done with it. - m_app_context.delete_interpreter (); + app_context.delete_interpreter (); emit octave_finished_signal (exit_status); } + + void interpreter_qobject::confirm_shutdown (bool closenow) + { + // Wait for link thread to go to sleep state. + m_qt_link->lock (); + + m_qt_link->shutdown_confirmation (closenow); + + m_qt_link->unlock (); + + // Awake the worker thread so that it continues shutting down (or not). + m_qt_link->wake_all (); + } }