mi_load_progress: Restore current_uiout using a scoped_restore
Simply use a scoped_restore instead of manually saving and restoring current_uiout. gdb/ChangeLog: * mi/mi-main.c (mi_load_progress): Restore current_uiout using a scoped_restore.
This commit is contained in:
parent
bd77e8ff27
commit
5846367a24
|
@ -1,3 +1,8 @@
|
||||||
|
2017-09-16 Simon Marchi <simon.marchi@ericsson.com>
|
||||||
|
|
||||||
|
* mi/mi-main.c (mi_load_progress): Restore current_uiout using a
|
||||||
|
scoped_restore.
|
||||||
|
|
||||||
2017-09-16 Simon Marchi <simon.marchi@ericsson.com>
|
2017-09-16 Simon Marchi <simon.marchi@ericsson.com>
|
||||||
|
|
||||||
* mi/mi-main.c (mi_load_progress): Make uiout variable
|
* mi/mi-main.c (mi_load_progress): Make uiout variable
|
||||||
|
|
|
@ -2324,13 +2324,11 @@ mi_load_progress (const char *section_name,
|
||||||
static steady_clock::time_point last_update;
|
static steady_clock::time_point last_update;
|
||||||
static char *previous_sect_name = NULL;
|
static char *previous_sect_name = NULL;
|
||||||
int new_section;
|
int new_section;
|
||||||
struct ui_out *saved_uiout;
|
|
||||||
struct mi_interp *mi = (struct mi_interp *) current_interpreter ();
|
struct mi_interp *mi = (struct mi_interp *) current_interpreter ();
|
||||||
|
|
||||||
/* This function is called through deprecated_show_load_progress
|
/* This function is called through deprecated_show_load_progress
|
||||||
which means uiout may not be correct. Fix it for the duration
|
which means uiout may not be correct. Fix it for the duration
|
||||||
of this function. */
|
of this function. */
|
||||||
saved_uiout = current_uiout;
|
|
||||||
|
|
||||||
std::unique_ptr<ui_out> uiout;
|
std::unique_ptr<ui_out> uiout;
|
||||||
|
|
||||||
|
@ -2344,7 +2342,8 @@ mi_load_progress (const char *section_name,
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
current_uiout = uiout.get ();
|
scoped_restore save_uiout
|
||||||
|
= make_scoped_restore (¤t_uiout, uiout.get ());
|
||||||
|
|
||||||
new_section = (previous_sect_name ?
|
new_section = (previous_sect_name ?
|
||||||
strcmp (previous_sect_name, section_name) : 1);
|
strcmp (previous_sect_name, section_name) : 1);
|
||||||
|
@ -2386,8 +2385,6 @@ mi_load_progress (const char *section_name,
|
||||||
fputs_unfiltered ("\n", mi->raw_stdout);
|
fputs_unfiltered ("\n", mi->raw_stdout);
|
||||||
gdb_flush (mi->raw_stdout);
|
gdb_flush (mi->raw_stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
current_uiout = saved_uiout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue