changeset 28985:47107a0979cd stable

avoid repeating last command when using F9 in debug mode (bug #57634) * octave-qscintilla.cc (octave_qscintilla): connect signal ctx_menu_run_finished_signal with new parameters; (contextmenu_run): compacter ouotput, get debug mode and current auto repeat mode, update signal parameters of ctx_menu_run_finished_signal; (ctx_menu_run_finished): new parameters for debug mode and auto repeat mode, restore old auto repeat mode in interpreter thread * octave-qscintilla.h: ctx_menu_run_finished_signal and related slot with additional parameters
author Torsten Lilge <ttl-octave@mailbox.org>
date Thu, 22 Oct 2020 22:58:25 +0200
parents 6d37fa1a786e
children 9a9d85ba4111 a2b4cd42a9cc
files libgui/src/m-editor/octave-qscintilla.cc libgui/src/m-editor/octave-qscintilla.h
diffstat 2 files changed, 33 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/octave-qscintilla.cc	Wed Oct 21 22:26:43 2020 +0200
+++ b/libgui/src/m-editor/octave-qscintilla.cc	Thu Oct 22 22:58:25 2020 +0200
@@ -121,9 +121,9 @@
              this, SLOT (cursor_position_changed (int, int)));
 
     connect (this, SIGNAL (ctx_menu_run_finished_signal (bool, int, QTemporaryFile*,
-                                                         QTemporaryFile*)),
+                                                         QTemporaryFile*, bool, bool)),
              this, SLOT (ctx_menu_run_finished (bool, int, QTemporaryFile*,
-                                                QTemporaryFile*)),
+                                                QTemporaryFile*, bool, bool)),
              Qt::QueuedConnection);
 
     // clear scintilla edit shortcuts that are handled by the editor
@@ -824,7 +824,7 @@
         hist += line_history + "\n";
       }
 
-    octave_stdout << hist.toStdString () << "\n";
+    octave_stdout << hist.toStdString ();
 
     // Create tmp file with the code to be executed by the interpreter
     QPointer<QTemporaryFile> tmp_file
@@ -871,8 +871,6 @@
     bool show_dbg_file = settings->value (ed_show_dbg_file).toBool ();
     settings->setValue (ed_show_dbg_file.key, false);
 
-    emit focus_console_after_command_signal ();
-
     // Let the interpreter execute the tmp file
     emit interpreter_event
       ([this, tmp_file, tmp_hist, show_dbg_file] (interpreter& interp)
@@ -885,6 +883,14 @@
 
          int err_line = -1;   // For storing the line of a poss. error
 
+         // Get current state of auto command repeat in debug mode
+         octave_value_list ovl_dbg = Fisdebugmode (interp);
+         bool dbg = ovl_dbg(0).bool_value ();
+         octave_value_list ovl_auto_repeat = ovl (true);
+         if (dbg)
+           ovl_auto_repeat = Fauto_repeat_debug_command (interp, ovl (false), 1);
+         bool auto_repeat = ovl_auto_repeat(0).bool_value ();
+
          try
            {
              // Do the job
@@ -943,7 +949,8 @@
 
              // Clean up before throwing the modified error.
              emit ctx_menu_run_finished_signal (show_dbg_file, err_line,
-                                                tmp_file, tmp_hist);
+                                                tmp_file, tmp_hist,
+                                                dbg, auto_repeat);
 
              // New exception with updated message and stack
              octave::execution_exception ee (e.err_type (),e.identifier (),
@@ -954,8 +961,10 @@
            }
 
          // Clean up
+
          emit ctx_menu_run_finished_signal (show_dbg_file, err_line,
-                                            tmp_file, tmp_hist);
+                                            tmp_file, tmp_hist,
+                                            dbg, auto_repeat);
 
          command_editor::erase_empty_line (true);
          command_editor::replace_line ("");
@@ -964,13 +973,16 @@
          command_editor::interrupt_event_loop ();
          command_editor::accept_line ();
          command_editor::erase_empty_line (true);
+
        });
   }
 
   void octave_qscintilla::ctx_menu_run_finished (bool show_dbg_file, int,
-                                                 QTemporaryFile* tmp_file,
-                                                 QTemporaryFile* tmp_hist)
+                      QTemporaryFile* tmp_file, QTemporaryFile* tmp_hist,
+                      bool dbg, bool auto_repeat)
   {
+    emit focus_console_after_command_signal ();
+
     // TODO: Use line nr. (int argument) of possible error for removing
     //       lines from history that were never executed. For this,
     //       possible lines from commands at a debug prompt must be
@@ -980,6 +992,14 @@
     settings->setValue (ed_show_dbg_file.key, show_dbg_file);
     rmgr.remove_tmp_file (tmp_file);
     rmgr.remove_tmp_file (tmp_hist);
+
+    emit interpreter_event
+      ([this, dbg, auto_repeat] (interpreter& interp)
+       {
+         // INTERPRETER THREAD
+         if (dbg)
+           Fauto_repeat_debug_command (interp, ovl (auto_repeat));
+       });
   }
 
 
--- a/libgui/src/m-editor/octave-qscintilla.h	Wed Oct 21 22:26:43 2020 +0200
+++ b/libgui/src/m-editor/octave-qscintilla.h	Thu Oct 22 22:58:25 2020 +0200
@@ -91,12 +91,14 @@
     void context_menu_break_condition_signal (int);
     void context_menu_break_once (int);
     void interpreter_event (const meth_callback& meth);
-    void ctx_menu_run_finished_signal (bool, int, QTemporaryFile*, QTemporaryFile*);
+    void ctx_menu_run_finished_signal (bool, int, QTemporaryFile*,
+                                       QTemporaryFile*, bool, bool);
     void focus_console_after_command_signal (void);
 
   private slots:
 
-    void ctx_menu_run_finished (bool, int, QTemporaryFile*, QTemporaryFile*);
+    void ctx_menu_run_finished (bool, int, QTemporaryFile*, QTemporaryFile*,
+                                bool, bool);
 
     void contextmenu_help (bool);
     void contextmenu_doc (bool);