diff --git a/bochs/gui/paramtree.cc b/bochs/gui/paramtree.cc index 136c63f42..4130d17ca 100644 --- a/bochs/gui/paramtree.cc +++ b/bochs/gui/paramtree.cc @@ -934,7 +934,6 @@ bx_list_c::~bx_list_c() delete [] list; } if (title != NULL) delete [] title; - if (choice != NULL) delete choice; } void bx_list_c::init(const char *list_title) @@ -947,8 +946,7 @@ void bx_list_c::init(const char *list_title) this->title[0] = 0; } this->options = 0; - this->choice = new bx_param_num_c(NULL, - "list_choice", "", "", 0, BX_MAX_BIT64S, 1); + this->choice = 1; } void bx_list_c::set_parent(bx_param_c *newparent) diff --git a/bochs/gui/paramtree.h b/bochs/gui/paramtree.h index cbfceab2b..215c4a8b5 100644 --- a/bochs/gui/paramtree.h +++ b/bochs/gui/paramtree.h @@ -439,9 +439,9 @@ protected: bx_param_c **list; int size, maxsize; // for a menu, the value of choice before the call to "ask" is default. - // After ask, choice holds the value that the user chose. Choice defaults + // After ask, choice holds the value that the user chose. Choice defaults // to 1 in the constructor. - bx_param_num_c *choice; + int choice; // title of the menu or series char *title; void init(const char *list_title); @@ -478,7 +478,8 @@ public: bx_param_c *get(int index); bx_param_c *get_by_name(const char *name); int get_size() const { return size; } - bx_param_num_c *get_choice() { return choice; } + int get_choice() const { return choice; } + void set_choice(int new_choice) { choice = new_choice; } char *get_title() { return title; } void set_parent(bx_param_c *newparent); bx_param_c *get_parent() { return parent; } diff --git a/bochs/gui/textconfig.cc b/bochs/gui/textconfig.cc index 6e497d3a0..e07657e2d 100644 --- a/bochs/gui/textconfig.cc +++ b/bochs/gui/textconfig.cc @@ -95,6 +95,7 @@ int ask_uint(const char *prompt, const char *help, Bit32u min, Bit32u max, Bit32 assert(base==10 || base==16); while (1) { printf(prompt, the_default); + fflush(stdout); if (!fgets(buffer, sizeof(buffer), stdin)) return -1; clean = clean_string(buffer); @@ -139,6 +140,7 @@ int ask_int(const char *prompt, const char *help, Bit32s min, Bit32s max, Bit32s int illegal; while (1) { printf(prompt, the_default); + fflush(stdout); if (!fgets(buffer, sizeof(buffer), stdin)) return -1; clean = clean_string(buffer); @@ -172,6 +174,7 @@ int ask_menu(const char *prompt, const char *help, int n_choices, const char *ch *out = -1; while (1) { printf(prompt, choice[the_default]); + fflush(stdout); if (!fgets(buffer, sizeof(buffer), stdin)) return -1; clean = clean_string(buffer); @@ -208,6 +211,7 @@ int ask_yn(const char *prompt, const char *help, Bit32u the_default, Bit32u *out while (1) { // if there's a %s field, substitute in the default yes/no. printf(prompt, the_default ? "yes" : "no"); + fflush(stdout); if (!fgets(buffer, sizeof(buffer), stdin)) return -1; clean = clean_string(buffer); @@ -240,6 +244,7 @@ int ask_string(const char *prompt, const char *the_default, char *out) assert(the_default != out); out[0] = 0; printf(prompt, the_default); + fflush(stdout); if (fgets(buffer, sizeof(buffer), stdin) == NULL) return -1; clean = clean_string(buffer); @@ -372,14 +377,13 @@ int do_menu(const char *pname) { bx_list_c *menu = (bx_list_c *)SIM->get_param(pname, NULL); while (1) { - menu->get_choice()->set(0); + menu->set_choice(0); int status = menu->text_ask(stdin, stderr); if (status < 0) return status; - bx_param_num_c *choice = menu->get_choice(); - if (choice->get() < 1) - return choice->get(); + if (menu->get_choice() < 1) + return menu->get_choice(); else { - int index = choice->get() - 1; // choosing 1 means list[0] + int index = menu->get_choice() - 1; // choosing 1 means list[0] bx_param_c *chosen = menu->get(index); assert(chosen != NULL); if (chosen->get_enabled()) { @@ -995,12 +999,11 @@ int bx_list_c::text_ask(FILE *fpin, FILE *fpout) } } fprintf(fpout, "\n"); - Bit32u n = choice->get(); + Bit32u n = (Bit32u) choice; int min = (options & SHOW_PARENT) ? 0 : 1; int max = size; int status = ask_uint("Please choose one: [%d] ", "", min, max, n, &n, 10); if (status < 0) return status; - choice->set(n); } return 0; }