changeset 16432:fe4cd846c3e7

separate octave interpreter thread creation from execution * main-window.cc (main_window::construct): Call octave_qt_link::execute_interpreter after all signal connections are made. * libgui/src/module.mk (octave_gui_MOC): Remove src/moc-octave-main-thread.cc from the list. * octave-main-thread.h, octave-main-thread.cc (octave_main_thread::execute_interpreter): New function. Call start. (octave_main_thread::ready): Delete signal and all uses. * octave_qt_link.h, octave_qt_link.cc (octave_qt_link::octave_qt_link): Don't call start for _main_thread. (octave_qt_link::execute_interpreter): New function.
author John W. Eaton <jwe@octave.org>
date Thu, 04 Apr 2013 13:27:21 -0400
parents 5982d469f79b
children 2c8860d563e5
files libgui/src/main-window.cc libgui/src/module.mk libgui/src/octave-main-thread.cc libgui/src/octave-main-thread.h libgui/src/octave-qt-link.cc libgui/src/octave-qt-link.h
diffstat 6 files changed, 26 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/main-window.cc	Thu Apr 04 13:20:43 2013 -0400
+++ b/libgui/src/main-window.cc	Thu Apr 04 13:27:21 2013 -0400
@@ -1184,6 +1184,8 @@
            _file_editor,
            SLOT (handle_delete_debugger_pointer_request (const QString&, int)));
 
+  _octave_qt_link->execute_interpreter ();
+
   octave_link::connect_link (_octave_qt_link);
 
   octave_link::register_event_listener (_octave_qt_event_listener);
--- a/libgui/src/module.mk	Thu Apr 04 13:20:43 2013 -0400
+++ b/libgui/src/module.mk	Thu Apr 04 13:27:21 2013 -0400
@@ -71,7 +71,6 @@
   src/moc-files-dockwidget.cc \
   src/moc-history-dockwidget.cc \
   src/moc-main-window.cc \
-  src/moc-octave-main-thread.cc \
   src/moc-octave-qt-event-listener.cc \
   src/moc-octave-qt-link.cc \
   src/moc-settings-dialog.cc \
--- a/libgui/src/octave-main-thread.cc	Thu Apr 04 13:20:43 2013 -0400
+++ b/libgui/src/octave-main-thread.cc	Thu Apr 04 13:27:21 2013 -0400
@@ -1,5 +1,6 @@
 /*
 
+Copyright (C) 2013 John W. Eaton
 Copyright (C) 2011-2012 Jacob Dawid
 
 This file is part of Octave.
@@ -35,20 +36,20 @@
 #include "octave-main-thread.h"
 #include "octave-link.h"
 
-octave_main_thread::octave_main_thread () : QThread ()
-{
-}
-
 void
-octave_main_thread::run ()
+octave_main_thread::run (void)
 {
   // Matlab uses "C" locale for LC_NUMERIC class regardless of local setting
   setlocale (LC_NUMERIC, "C");
 
-  emit ready ();
-
   octave_initialize_interpreter (octave_cmdline_argc, octave_cmdline_argv,
                                  octave_embedded);
 
   octave_execute_interpreter ();
 }
+
+void
+octave_main_thread::execute_interpreter (void)
+{
+  start ();
+}
--- a/libgui/src/octave-main-thread.h	Thu Apr 04 13:20:43 2013 -0400
+++ b/libgui/src/octave-main-thread.h	Thu Apr 04 13:27:21 2013 -0400
@@ -1,5 +1,6 @@
 /*
 
+Copyright (C) 2013 John W. Eaton
 Copyright (C) 2011-2012 Jacob Dawid
 
 This file is part of Octave.
@@ -32,19 +33,17 @@
   */
 class octave_main_thread : public QThread
 {
-  Q_OBJECT
 public:
-  /** Creates a new thread running octave_main. */
-  octave_main_thread ();
+  // Create a new thread for running the octave interpreter.
+  octave_main_thread (void) : QThread () { }
 
-signals:
-  /** This signal will be emitted when the thread is about to actually
-    * run octave_main. */
-  void ready();
+  // Start the thread and initialize and execute the octave
+  // interpreter.
+  void execute_interpreter (void);
 
 protected:
-  /** Runs octave_main. */
-  void run ();
+  // Avoid exec.  Run the octave interpreter in the new thread.
+  void run (void);
 };
 
 #endif // OCTAVEMAINTHREAD_H
--- a/libgui/src/octave-qt-link.cc	Thu Apr 04 13:20:43 2013 -0400
+++ b/libgui/src/octave-qt-link.cc	Thu Apr 04 13:27:21 2013 -0400
@@ -35,8 +35,12 @@
 octave_qt_link::octave_qt_link (void)
   : octave_link (), main_thread (new octave_main_thread)
 {
-  // Start the first one.
-  main_thread->start ();
+}
+
+void
+octave_qt_link::execute_interpreter (void)
+{
+  main_thread->execute_interpreter ();
 }
 
 void
--- a/libgui/src/octave-qt-link.h	Thu Apr 04 13:20:43 2013 -0400
+++ b/libgui/src/octave-qt-link.h	Thu Apr 04 13:27:21 2013 -0400
@@ -51,6 +51,8 @@
 
   ~octave_qt_link (void) { }
 
+  void execute_interpreter (void);
+
   void do_update_workspace (void);
 
   void do_set_history (const string_vector& hist);