Fix T55032: Redo w/ file saved in edit-mode failed

It's important edit-mode has a step stored for redo to work,
file load now ensures this in a generic way.
This commit is contained in:
Campbell Barton 2018-05-15 19:30:59 +02:00
parent 91504ed26e
commit 4461be1b72
3 changed files with 19 additions and 8 deletions

View File

@ -137,6 +137,7 @@ void BKE_undosys_stack_destroy(UndoStack *ustack);
void BKE_undosys_stack_clear(UndoStack *ustack);
bool BKE_undosys_stack_has_undo(UndoStack *ustack, const char *name);
void BKE_undosys_stack_init_from_main(UndoStack *ustack, struct Main *bmain);
void BKE_undosys_stack_init_from_context(UndoStack *ustack, struct bContext *C);
UndoStep *BKE_undosys_stack_active_with_type(UndoStack *ustack, const UndoType *ut);
UndoStep *BKE_undosys_stack_init_or_active_with_type(UndoStack *ustack, const UndoType *ut);
void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size_t memory_limit);

View File

@ -251,6 +251,15 @@ void BKE_undosys_stack_init_from_main(UndoStack *ustack, struct Main *bmain)
undosys_stack_push_main(ustack, "original", bmain);
}
/* called after 'BKE_undosys_stack_init_from_main' */
void BKE_undosys_stack_init_from_context(UndoStack *ustack, bContext *C)
{
const UndoType *ut = BKE_undosys_type_from_context(C);
if ((ut != NULL) && (ut != BKE_UNDOSYS_TYPE_MEMFILE) && (ut->mode == BKE_UNDOTYPE_MODE_STORE)) {
BKE_undosys_step_push_with_type(ustack, C, "original mode", ut);
}
}
/* name optional */
bool BKE_undosys_stack_has_undo(UndoStack *ustack, const char *name)
{

View File

@ -516,14 +516,7 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo
if (addons_loaded) {
wm_file_read_report(C);
}
if (!G.background) {
/* in background mode this makes it hard to load
* a blend file and do anything since the screen
* won't be set to a valid value again */
CTX_wm_window_set(C, NULL); /* exits queues */
}
if (!G.background) {
if (wm->undo_stack == NULL) {
wm->undo_stack = BKE_undosys_stack_create();
@ -532,6 +525,14 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo
BKE_undosys_stack_clear(wm->undo_stack);
}
BKE_undosys_stack_init_from_main(wm->undo_stack, CTX_data_main(C));
BKE_undosys_stack_init_from_context(wm->undo_stack, C);
}
if (!G.background) {
/* in background mode this makes it hard to load
* a blend file and do anything since the screen
* won't be set to a valid value again */
CTX_wm_window_set(C, NULL); /* exits queues */
}
}