undo/redo becomes unsafe after load new scenario, so clear it
This commit is contained in:
@@ -258,6 +258,8 @@ static bool handle_lb_action(int i){
|
||||
if(!file_to_load.empty() && load_scenario(file_to_load, scenario)) {
|
||||
set_pref("LastScenario", file_to_load.string());
|
||||
restore_editor_state();
|
||||
undo_list.clear();
|
||||
update_edit_menu();
|
||||
} else if(!file_to_load.empty())
|
||||
// If we tried to load but failed, the scenario record is messed up, so boot to start screen.
|
||||
set_up_start_screen();
|
||||
|
@@ -52,6 +52,8 @@ void set_up_apple_events() {
|
||||
std::copy(msg.get(), msg.get() + len, std::inserter(fileName, fileName.begin()));
|
||||
|
||||
if(load_scenario(fileName, scenario)) {
|
||||
undo_list.clear();
|
||||
update_edit_menu();
|
||||
set_pref("LastScenario", fileName);
|
||||
restore_editor_state();
|
||||
change_made = false;
|
||||
|
@@ -3280,6 +3280,9 @@ bool build_scenario() {
|
||||
if(!edit_make_scen_2(width, height, lg, med, sm, default_town))
|
||||
return false;
|
||||
|
||||
undo_list.clear();
|
||||
update_edit_menu();
|
||||
|
||||
scenario = cScenario();
|
||||
scenario.scen_name = title;
|
||||
scenario.contact_info[0] = author;
|
||||
|
@@ -332,6 +332,8 @@ static void process_args(int argc, char* argv[]) {
|
||||
}
|
||||
if(!file.empty()) {
|
||||
if(load_scenario(file, scenario)) {
|
||||
// On first launch, no need to clear the undo_list
|
||||
|
||||
set_pref("LastScenario", file);
|
||||
restore_editor_state();
|
||||
change_made = false;
|
||||
@@ -516,6 +518,8 @@ void handle_menu_choice(eMenu item_hit) {
|
||||
break;
|
||||
file_to_load = item_hit == eMenu::FILE_OPEN ? nav_get_scenario() : scenario.scen_file;
|
||||
if(!file_to_load.empty() && load_scenario(file_to_load, scenario)) {
|
||||
undo_list.clear();
|
||||
update_edit_menu();
|
||||
set_pref("LastScenario", file_to_load.string());
|
||||
restore_editor_state();
|
||||
change_made = false;
|
||||
|
Reference in New Issue
Block a user