changeset 27404:a3ec8c75ece3

avoid possible threading issue when running file from GUI editor * file-editor.cc (file_editor::request_run_file): Use interpreter event to check debug status, then emit signal to execute dbcont or run file from there.
author John W. Eaton <jwe@octave.org>
date Fri, 13 Sep 2019 08:02:45 -0400
parents 27967cb3dea5
children 646efbb5f407
files libgui/src/m-editor/file-editor.cc
diffstat 1 files changed, 20 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc	Fri Sep 13 07:38:36 2019 -0400
+++ b/libgui/src/m-editor/file-editor.cc	Fri Sep 13 08:02:45 2019 -0400
@@ -44,14 +44,17 @@
 #include <QVBoxLayout>
 #include <Qsci/qscicommandset.h>
 
-#include "event-manager.h"
-#include "oct-env.h"
-#include "oct-map.h"
-#include "utils.h"
-
 #include "main-window.h"
 #include "gui-preferences.h"
 
+#include "oct-env.h"
+
+#include "event-manager.h"
+#include "interpreter.h"
+#include "oct-map.h"
+#include "pt-eval.h"
+#include "utils.h"
+
 namespace octave
 {
   // Functions of the the reimplemented tab widget
@@ -563,10 +566,18 @@
 
   void file_editor::request_run_file (bool)
   {
-    if ((Fisdebugmode ())(0).is_true ())
-      emit request_dbcont_signal ();
-    else
-      emit fetab_run_file (m_tab_widget->currentWidget ());
+    emit interpreter_event
+      ([this] (interpreter& interp)
+       {
+         // INTERPRETER THREAD
+
+         tree_evaluator& tw = interp.get_evaluator ();
+
+         if (tw.in_debug_repl ())
+           emit request_dbcont_signal ();
+         else
+           emit fetab_run_file (m_tab_widget->currentWidget ());
+       });
   }
 
   void file_editor::request_step_into_file ()