changeset 26873:9ec36417c262

debug step starts script if not already running in debug mode (bug #44728) * file-editor-tab.cc (run_file): new additional parameter whether just run or step through the file * file-editor-tab.h: run_file with new parameter * file-editor.cc (check_actions): emit new signal for indicating the existence of tabs; (request_step_into_file): new slote for running a file for stepping through it; (add_file_editor_tab): update connection of signal fetab_run_file with slot run_file with new parameter; * file-editor.h: updated fetab_run_file signal with new parameter, new signal editor_tabs_changed for changed number of tabs, new slot request_step_into_file * main-window.cc (debug_step_over): check for debug state; if in debug mode just call dbstep or start stepping through the file otherwise; (construct): connect new signal for stepping through the current editor file with the related slot of the editor, connect new editor signal indicating the exsitence of tabs with the related slot in the main window; (editor_tabs_changed): new slot for editor signal on changed tabs; (handle_exit_debugger): only set debug step action to disabled if editor does not have tabs * main-window.h: new signal for stepping through the current editor file, new slot for changed existence of edtior tabs, new class variable holding whether editor has tabs or not
author Torsten Lilge <ttl-octave@mailbox.org>
date Sun, 10 Mar 2019 16:40:35 +0100
parents 07d0ab1f1ec3
children 69722280102c
files libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor-tab.h libgui/src/m-editor/file-editor.cc libgui/src/m-editor/file-editor.h libgui/src/main-window.cc libgui/src/main-window.h
diffstat 6 files changed, 47 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Sun Mar 10 14:07:25 2019 +0100
+++ b/libgui/src/m-editor/file-editor-tab.cc	Sun Mar 10 16:40:35 2019 +0100
@@ -909,7 +909,7 @@
     delete printer;
   }
 
-  void file_editor_tab::run_file (const QWidget *ID)
+  void file_editor_tab::run_file (const QWidget *ID, bool step_into)
   {
     if (ID != this)
       return;
@@ -921,6 +921,9 @@
           return;   // still invalid filename: "save as" was cancelled
       }
 
+    if (step_into)
+      handle_request_add_breakpoint (1, QString ());
+
     QFileInfo info (_file_name);
     emit run_file_signal (info);
   }
--- a/libgui/src/m-editor/file-editor-tab.h	Sun Mar 10 14:07:25 2019 +0100
+++ b/libgui/src/m-editor/file-editor-tab.h	Sun Mar 10 16:40:35 2019 +0100
@@ -94,7 +94,7 @@
                     bool remove_on_success);
     void save_file_as (const QWidget *ID);
     void print_file (const QWidget *ID);
-    void run_file (const QWidget *ID);
+    void run_file (const QWidget *ID, bool step_into = false);
     void context_run (const QWidget *ID);
     void toggle_bookmark (const QWidget *ID);
     void next_bookmark (const QWidget *ID);
--- a/libgui/src/m-editor/file-editor.cc	Sun Mar 10 14:07:25 2019 +0100
+++ b/libgui/src/m-editor/file-editor.cc	Sun Mar 10 16:40:35 2019 +0100
@@ -194,6 +194,8 @@
     m_close_action->setEnabled (have_tabs);
     m_close_all_action->setEnabled (have_tabs);
     m_close_others_action->setEnabled (have_tabs && m_tab_widget->count () > 1);
+
+    emit editor_tabs_changed_signal (have_tabs);
   }
 
   // empty_script determines whether we have to create an empty script
@@ -542,6 +544,11 @@
     emit fetab_run_file (m_tab_widget->currentWidget ());
   }
 
+  void file_editor::request_step_into_file ()
+  {
+    emit fetab_run_file (m_tab_widget->currentWidget (), true);
+  }
+
   void file_editor::request_context_run (bool)
   {
     emit fetab_context_run (m_tab_widget->currentWidget ());
@@ -2240,8 +2247,8 @@
     connect (this, SIGNAL (fetab_print_file (const QWidget*)),
              f, SLOT (print_file (const QWidget*)));
 
-    connect (this, SIGNAL (fetab_run_file (const QWidget*)),
-             f, SLOT (run_file (const QWidget*)));
+    connect (this, SIGNAL (fetab_run_file (const QWidget*, bool)),
+             f, SLOT (run_file (const QWidget*, bool)));
 
     connect (this, SIGNAL (fetab_context_run (const QWidget*)),
              f, SLOT (context_run (const QWidget*)));
--- a/libgui/src/m-editor/file-editor.h	Sun Mar 10 14:07:25 2019 +0100
+++ b/libgui/src/m-editor/file-editor.h	Sun Mar 10 16:40:35 2019 +0100
@@ -136,7 +136,7 @@
     void fetab_save_file (const QWidget *ID);
     void fetab_save_file_as (const QWidget *ID);
     void fetab_print_file (const QWidget *ID);
-    void fetab_run_file (const QWidget *ID);
+    void fetab_run_file (const QWidget *ID, bool step_into = false);
     void fetab_context_run (const QWidget *ID);
     void fetab_toggle_bookmark (const QWidget *ID);
     void fetab_next_bookmark (const QWidget *ID);
@@ -176,6 +176,8 @@
     void request_open_file_external (const QString& file_name, int line);
     void file_loaded_signal (void);
 
+    void editor_tabs_changed_signal (bool);
+
   public slots:
 
     void focus (void);
@@ -198,6 +200,7 @@
     void request_save_file (bool);
     void request_save_file_as (bool);
     void request_run_file (bool);
+    void request_step_into_file ();
     void request_context_run (bool);
     void request_toggle_bookmark (bool);
     void request_next_bookmark (bool);
--- a/libgui/src/main-window.cc	Sun Mar 10 14:07:25 2019 +0100
+++ b/libgui/src/main-window.cc	Sun Mar 10 16:40:35 2019 +0100
@@ -1011,7 +1011,7 @@
 
     m_debug_continue->setEnabled (false);
     m_debug_step_into->setEnabled (false);
-    m_debug_step_over->setEnabled (false);
+    m_debug_step_over->setEnabled (m_editor_has_tabs);
     m_debug_step_out->setEnabled (false);
     m_debug_quit->setEnabled (false);
 
@@ -1035,9 +1035,18 @@
 
   void main_window::debug_step_over (void)
   {
-    octave_cmd_debug *cmd
-      = new octave_cmd_debug ("step", m_suppress_dbg_location);
-    queue_cmd (cmd);
+    if (m_debug_quit->isEnabled ())
+      {
+        // We are in debug mode, just call dbstep
+        octave_cmd_debug *cmd
+          = new octave_cmd_debug ("step", m_suppress_dbg_location);
+        queue_cmd (cmd);
+      }
+    else
+      {
+        // Not in debug mode: "step into" the current editor file
+        emit step_into_file_signal ();
+      }
   }
 
   void main_window::debug_step_out (void)
@@ -1768,6 +1777,12 @@
     connect (this, SIGNAL (editor_focus_changed (bool)),
              m_editor_window, SLOT (enable_menu_shortcuts (bool)));
 
+    connect (this, SIGNAL (step_into_file_signal (void)),
+             m_editor_window, SLOT (request_step_into_file (void)));
+
+    connect (m_editor_window, SIGNAL (editor_tabs_changed_signal (bool)),
+             this, SLOT (editor_tabs_changed (bool)));
+
     connect (m_editor_window,
              SIGNAL (request_open_file_external (const QString&, int)),
              m_external_editor,
@@ -2231,6 +2246,13 @@
                                               SLOT (debug_quit (void)));
   }
 
+  void main_window::editor_tabs_changed (bool have_tabs)
+  {
+    // Set state of action which depend on the existance of editor tabs
+    m_editor_has_tabs = have_tabs;
+    m_debug_step_over->setEnabled (have_tabs);
+  }
+
   QAction * main_window::construct_window_menu_item (QMenu *p,
                                                      const QString& item,
                                                      bool checkable,
--- a/libgui/src/main-window.h	Sun Mar 10 14:07:25 2019 +0100
+++ b/libgui/src/main-window.h	Sun Mar 10 16:40:35 2019 +0100
@@ -123,6 +123,7 @@
     void new_file_signal (const QString&);
     void open_file_signal (const QString&);
     void open_file_signal (const QString& file, const QString& enc, int line);
+    void step_into_file_signal (void);
 
     void show_doc_signal (const QString&);
     void register_doc_signal (const QString&);
@@ -194,6 +195,7 @@
     void debug_step_over (void);
     void debug_step_out (void);
     void debug_quit (void);
+    void editor_tabs_changed (bool);
 
     void request_open_file (void);
     void request_new_script (const QString& commands = QString ());
@@ -455,6 +457,7 @@
     //!@{
     bool m_prevent_readline_conflicts;
     bool m_suppress_dbg_location;
+    bool m_editor_has_tabs;
 
     //! Flag for closing the whole application.