Limit variable scope.

Also avoid shadowing the variable res.

Issue found by cppcheck.
This commit is contained in:
Mark de Wever 2014-02-09 19:15:41 +01:00
parent 6f3dd3b1e1
commit 3b1b13e96d

View File

@ -564,14 +564,13 @@ void context_manager::save_map_as_dialog()
}
const std::string old_input_name = input_name;
int res = 0;
int overwrite_res = 1;
do {
input_name = old_input_name;
res = dialogs::show_file_chooser_dialog_save(gui_, input_name, _("Save the Map As"));
int res = dialogs::show_file_chooser_dialog_save(gui_, input_name, _("Save the Map As"));
if (res == 0) {
if (file_exists(input_name)) {
const int res = gui2::show_message(gui_.video(), "",
res = gui2::show_message(gui_.video(), "",
_("The file already exists. Do you want to overwrite it?"), gui2::tmessage::yes_no_buttons);
overwrite_res = gui2::twindow::CANCEL == res ? 1 : 0;
} else {
@ -593,14 +592,13 @@ void context_manager::save_scenario_as_dialog()
}
const std::string old_input_name = input_name;
int res = 0;
int overwrite_res = 1;
do {
input_name = old_input_name;
res = dialogs::show_file_chooser_dialog_save(gui_, input_name, _("Save the Scenario As"));
int res = dialogs::show_file_chooser_dialog_save(gui_, input_name, _("Save the Scenario As"));
if (res == 0) {
if (file_exists(input_name)) {
const int res = gui2::show_message(gui_.video(), "",
res = gui2::show_message(gui_.video(), "",
_("The file already exists. Do you want to overwrite it?"), gui2::tmessage::yes_no_buttons);
overwrite_res = gui2::twindow::CANCEL == res ? 1 : 0;
} else {