diff libgui/src/m-editor/file-editor-tab.cc @ 25923:a7511a1489b8

call octave functions with return value from GUI (bug #47585) * file-editor-tab.cc (update_breakpoints): new function using octave_cmd_builtin for calling dbstatus; (update_breakpoints_handler) slot for the signal from the worker thread going through the list of returned breakpoints and update the markers of the breakpoints which are related to the current file; (handle_octave_result): removed this stub * file-editor-tab.h: new method update_breakpoints, new slot update_breakpoints_handler * file-editor.cc (request_open_file): call update_breakpoints for the new editor tab after the file contents has been loaded * main-window.cc (main_window): register octave_value_list as meta type allowing to send this data type via queued signal/slot connections; (handle_load_workspace_request): update usage of octave_cmd_builtin according to its new parameter list * octave-cmd.cc (octave_cmd_builtin::execute): call builtin function with return value list, if nargout is not zero, emit the signal with the returned list; (octave_cmd_builtin::init_cmd_retval): method for connecting the return value signal with the slot given by the caller * octave-cmd.h: (octave_cmd_builtin): add nargout as well as receiver and handler of the return value signals slot to the parameter list, call method for connecting the signal with the given slot; (argout_signal): new signal for passing the return values to the caller thread
author Torsten <mttl@mailbox.org>
date Mon, 08 Oct 2018 20:41:31 +0200
parents b33d4fbce33e
children 2eb71b83d3e2
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Mon Oct 08 10:27:32 2018 -0700
+++ b/libgui/src/m-editor/file-editor-tab.cc	Mon Oct 08 20:41:31 2018 +0200
@@ -1933,30 +1933,34 @@
       }
   }
 
-  // FIXME: See patch #8016 for a general way to get Octave results from
-  // commands processed in the background, e.g., dbstatus.
-  void file_editor_tab::handle_octave_result (QObject *requester,
-                                              QString& command,
-                                              octave_value_list&)
+  void file_editor_tab::update_breakpoints ()
   {
-    // Check if this object initiated the command.
-    if (requester == this)
+    if (_file_name.isEmpty ())
+      return;
+
+    octave_value_list argout = ovl ();
+
+    // Create and queue the command object
+    octave_cmd_builtin *cmd = new octave_cmd_builtin (&Fdbstatus, ovl (), 1,
+        this, SLOT (update_breakpoints_handler (const octave_value_list&)));
+
+    emit request_queue_cmd (cmd);
+  }
+
+  void file_editor_tab::update_breakpoints_handler (const octave_value_list& argout)
+  {
+    octave_map dbg = argout(0).map_value ();
+    octave_idx_type n_dbg = dbg.numel ();
+
+    Cell file = dbg.contents ("file");
+    Cell line = dbg.contents ("line");
+    Cell cond = dbg.contents ("cond");
+
+    for (octave_idx_type i = 0; i < n_dbg; i++)
       {
-        if (command == "dbstatus")
-          {
-            // Should be installing breakpoints in this file
-            /*
-              octave:1> result = dbstatus
-              result =
-
-              0x1 struct array containing the fields:
-
-              name
-              file
-              line
-            */
-            // Check for results that match "file".
-          }
+        if (file (i).string_value () == _file_name.toStdString ())
+          do_breakpoint_marker (true, this, line (i).int_value (),
+                                QString::fromStdString (cond (i).string_value ()));
       }
   }