diff libgui/src/main-window.h @ 23119:3107d3717cc2

refactor and simplify interpreter startup in GUI * octave-interpreter.h, octave-interpreter.cc: Delete files. Move classes from here to main-window.h, main-window.cc. * libgui/src/module.mk: Update. * main-window.h, main-window.cc (main_window::m_interpreter, main_window::m_main_thread): New data members. (main_window::main_window): Connect octave_interpreter::octave_ready_singal to main_window::handle_octave_ready slot. Create interpreter and main thread objects. (main_window::~main_window): Delete interpreter and main_thread objects. (main_window::interrupt_interpreter): New function. (main_window::construct_octave_qt_link): Connect singleShot timer to octave_interpreter::execute instead of main_window::execute_octave_interpreter. Don't connect command_window::interrupt_signal to _octave_qt_link::terminal_interrupt. Don't connect _workspace_model::rename_variable to main_window::handle_rename_variable_request. (main_window::construct): Connect command_window::interrupt signal to main_window::interrupt_interpreter. Connect _workspace_model::rename_variable to main_window::handle_rename_variable_request. (main_window::execute_octave_interpreter): Delete. * octave-qt-link.h, octave-qt-link.cc (octave_qt_link::main_thread, octave_qt_link::command_interpreter): Delete data members and all uses. (octave_qt_link::octave_qt_link): Don't create thread or command interpreter objects or connect signals to/from the command interpreter. (octave_qt_link::execute_interpreter): Delete. (octave_qt_link::terminal_interrupt): Delete.
author John W. Eaton <jwe@octave.org>
date Mon, 30 Jan 2017 17:38:12 -0500
parents 0fed4c678795
children 092078913d54
line wrap: on
line diff
--- a/libgui/src/main-window.h	Mon Jan 30 15:13:29 2017 -0500
+++ b/libgui/src/main-window.h	Mon Jan 30 17:38:12 2017 -0500
@@ -56,11 +56,43 @@
 #include "octave-qt-link.h"
 #include "resource-manager.h"
 #include "terminal-dock-widget.h"
+#include "thread-manager.h"
 #include "workspace-model.h"
 #include "workspace-view.h"
 
 class settings_dialog;
 
+class octave_interpreter : public QObject
+{
+  Q_OBJECT
+
+public:
+
+  // An object to manage the Octave interpreter.
+
+  octave_interpreter (octave::application *app_context);
+
+  ~octave_interpreter (void) = default;
+
+  void interrupt (void);
+
+signals:
+
+  void octave_ready_signal ();
+
+public slots:
+
+  // Initialize and execute the octave interpreter.
+
+  void execute (void);
+
+private:
+
+  octave_thread_manager thread_manager;
+
+  octave::application *m_app_context;
+};
+
 /**
  * @class MainWindow
  *
@@ -205,7 +237,6 @@
 
   void handle_show_doc (const QString &file);
 
-  void execute_octave_interpreter (void);
   void handle_octave_ready ();
 
   // find files dialog
@@ -221,11 +252,14 @@
   void clipboard_has_changed (QClipboard::Mode);
   void clear_clipboard ();
 
+  void interrupt_interpreter (void);
+
   // get the dockwidgets
   QList<octave_dock_widget *> get_dock_widget_list ()
   { return dock_widget_list (); }
 
 private slots:
+
   void disable_menu_shortcuts (bool disable);
 
 protected:
@@ -292,6 +326,10 @@
 
   octave::gui_application *m_app_context;
 
+  octave_interpreter *m_interpreter;
+
+  QThread *m_main_thread;
+
   workspace_model *_workspace_model;
 
   QHash<QMenu*, QStringList> _hash_menu_text;