From ca5909c7de7353d8005bf8fdcc020b8f14cc1603 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sun, 13 Aug 2017 10:47:32 -0600 Subject: Remove make_cleanup_ui_out_redirect_pop This patch introduces ui_out_redirect_pop. All uses of make_cleanup_ui_out_redirect_pop are replaced with this new class. ChangeLog 2017-09-09 Tom Tromey * mi/mi-interp.c (mi_user_selected_context_changed): Use ui_out_redirect_pop. * guile/scm-ports.c (ioscm_with_output_to_port_worker): Use ui_out_redirect_pop. * utils.c (do_ui_out_redirect_pop) (make_cleanup_ui_out_redirect_pop): Remove. * top.c (execute_command_to_string): Use ui_out_redirect_pop. * utils.h (make_cleanup_ui_out_redirect_pop): Remove. * ui-out.h (ui_out_redirect_pop): New class. --- gdb/guile/scm-ports.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'gdb/guile') diff --git a/gdb/guile/scm-ports.c b/gdb/guile/scm-ports.c index 735abc2..78187c4 100644 --- a/gdb/guile/scm-ports.c +++ b/gdb/guile/scm-ports.c @@ -26,6 +26,7 @@ #include "top.h" #include "target.h" #include "guile-internal.h" +#include "common/gdb_optional.h" #ifdef HAVE_POLL #if defined (HAVE_POLL_H) @@ -477,17 +478,20 @@ ioscm_with_output_to_port_worker (SCM port, SCM thunk, enum oport oport, scoped_restore save_file = make_scoped_restore (oport == GDB_STDERR ? &gdb_stderr : &gdb_stdout); - if (oport == GDB_STDERR) - gdb_stderr = port_file.get (); - else - { - current_uiout->redirect (port_file.get ()); - make_cleanup_ui_out_redirect_pop (current_uiout); + { + gdb::optional redirect_popper; + if (oport == GDB_STDERR) + gdb_stderr = port_file.get (); + else + { + current_uiout->redirect (port_file.get ()); + redirect_popper.emplace (current_uiout); - gdb_stdout = port_file.get (); - } + gdb_stdout = port_file.get (); + } - result = gdbscm_safe_call_0 (thunk, NULL); + result = gdbscm_safe_call_0 (thunk, NULL); + } do_cleanups (cleanups); -- cgit v1.1