Fix undo crash with multiple scenes & windows
Creating a new window then a new scene would crash on undo because the undo step loaded would not contain the new windows scene. Regression introduced since 3.6.
This commit is contained in:
@@ -800,6 +800,19 @@ static void setup_app_data(bContext *C,
|
||||
wm_data_consistency_ensure(CTX_wm_manager(C), curscene, cur_view_layer);
|
||||
}
|
||||
|
||||
if (mode == LOAD_UNDO) {
|
||||
/* It's possible to undo into a time before the scene existed, in this case the window's scene
|
||||
* will be null. Since it doesn't make sense to remove the window, set it to the current scene.
|
||||
* NOTE: Redo will restore the active scene to the window so a reasonably consistent state
|
||||
* is maintained. We could do better by keeping a window/scene map for each undo step. */
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(bfd->main->wm.first);
|
||||
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
||||
if (win->scene == nullptr) {
|
||||
win->scene = curscene;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BLI_assert(BKE_main_namemap_validate(bfd->main));
|
||||
|
||||
if (mode != LOAD_UI) {
|
||||
|
||||
Reference in New Issue
Block a user