Mercurial > octave
changeset 27652:f18e48749a7a
fix running selected code by F9 in case of errors during execution
* octave-qscintilla.cc (contextmenu_run): use try/catch for being able
to clean up even in case of errors
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Thu, 07 Nov 2019 10:03:28 +0100 |
parents | c9ebcb9050b4 |
children | 3564d3999960 |
files | libgui/src/m-editor/octave-qscintilla.cc |
diffstat | 1 files changed, 21 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/octave-qscintilla.cc Thu Nov 07 10:03:25 2019 +0100 +++ b/libgui/src/m-editor/octave-qscintilla.cc Thu Nov 07 10:03:28 2019 +0100 @@ -884,9 +884,29 @@ // Add tmp dir to the path for echo/hist script octave_value_list path = ovl (QFileInfo (tmp_script->fileName ()).absolutePath ().toStdString ()); + + // Add tmp dir to the path Faddpath (interp, path); - interp.source_file (file); + + try + { + // Do the job + interp.source_file (file); + } + catch (const execution_exception& e) + { + // Catch errors otherwise the rest of the interpreter + // will not be executed (cleaning up). Clean up before. + Frmpath (interp, path); + emit ctx_menu_run_finished_signal (show_dbg_file, + tmp_file, tmp_hist, tmp_script); + throw (e); + } + + // Clean up Frmpath (interp, path); + emit ctx_menu_run_finished_signal (show_dbg_file, + tmp_file, tmp_hist, tmp_script); command_editor::replace_line (""); command_editor::set_initial_input (pending_input); @@ -894,9 +914,6 @@ command_editor::interrupt_event_loop (); command_editor::accept_line (); - // Done, restore settings and remove tmp files - emit ctx_menu_run_finished_signal (show_dbg_file, - tmp_file, tmp_hist, tmp_script); }); }