Add try & catch for load_game_config_for_game().
This guarantees that game config willd be restore after unsuccessful loading.
This commit is contained in:
parent
3de33c39f5
commit
7df2142fd8
1 changed files with 19 additions and 2 deletions
|
@ -105,7 +105,6 @@ void game_config_manager::load_game_config(FORCE_RELOAD_CONFIG force_reload)
|
|||
return;
|
||||
}
|
||||
|
||||
old_defines_map_ = cache_.get_preproc_map();
|
||||
loadscreen::global_loadscreen_manager loadscreen_manager(disp_.video());
|
||||
cursor::setter cur(cursor::WAIT);
|
||||
|
||||
|
@ -156,6 +155,8 @@ void game_config_manager::load_game_config(FORCE_RELOAD_CONFIG force_reload)
|
|||
throw;
|
||||
}
|
||||
|
||||
old_defines_map_ = cache_.get_preproc_map();
|
||||
|
||||
manager_state.set_status_success();
|
||||
|
||||
// Set new binary paths.
|
||||
|
@ -322,7 +323,23 @@ void game_config_manager::load_game_config_for_game(
|
|||
extra_defines.push_back(new_define);
|
||||
}
|
||||
|
||||
load_game_config(NO_FORCE_RELOAD);
|
||||
try{
|
||||
load_game_config(NO_FORCE_RELOAD);
|
||||
}
|
||||
catch(game::error& e) {
|
||||
cache_.clear_defines();
|
||||
|
||||
std::deque<define> previous_defines;
|
||||
BOOST_FOREACH(const preproc_map::value_type& preproc, old_defines_map_) {
|
||||
define new_define
|
||||
(new game_config::scoped_preproc_define(preproc.first));
|
||||
previous_defines.push_back(new_define);
|
||||
}
|
||||
|
||||
load_game_config(NO_FORCE_RELOAD);
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
game_config_manager_state::game_config_manager_state(config* game_config,
|
||||
|
|
Loading…
Add table
Reference in a new issue