changeset 21428:217e6e97085b

Prevent race conditions in GUI and interpreter initialization (bug #47326) * main-window.cc (main_window::execute_octave_interpreter): New slot. (main_window::construct_octave_qt_link): Defer starting the interpreter thread until after the QApplication main loop is running. * main-window.h (main_window::execute_octave_interpreter): Declare new slot.
author Mike Miller <mtmiller@octave.org>
date Thu, 10 Mar 2016 12:11:17 -0800
parents 067662ac6bfe
children f815b0145d1e
files libgui/src/main-window.cc libgui/src/main-window.h
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/main-window.cc	Wed Mar 09 20:05:27 2016 -0500
+++ b/libgui/src/main-window.cc	Thu Mar 10 12:11:17 2016 -0800
@@ -1583,9 +1583,17 @@
                _octave_qt_link, SLOT (terminal_interrupt (void)));
     }
 
+  octave_link::connect_link (_octave_qt_link);
+
+  // Defer initializing and executing the interpreter until after the main
+  // window and QApplication are running to prevent race conditions
+  QTimer::singleShot (0, this, SLOT (execute_octave_interpreter ()));
+}
+
+void
+main_window::execute_octave_interpreter (void)
+{
   _octave_qt_link->execute_interpreter ();
-
-  octave_link::connect_link (_octave_qt_link);
 }
 
 void
--- a/libgui/src/main-window.h	Wed Mar 09 20:05:27 2016 -0500
+++ b/libgui/src/main-window.h	Thu Mar 10 12:11:17 2016 -0800
@@ -206,6 +206,7 @@
 
   void handle_show_doc (const QString &file);
 
+  void execute_octave_interpreter (void);
   void handle_octave_ready ();
 
   // find files dialog