Fix T65886: Crash when deleting a scene when "New Main Window" is open.

When we delete a scene, we need to update to new scene pointer all main
widows that might be using it, not only the active one from the context...
This commit is contained in:
Bastien Montagne 2019-06-17 16:37:15 +02:00
parent 495aff71ca
commit f827811a42
Notes: blender-bot 2023-02-14 07:25:51 +01:00
Referenced by issue #65886, Crash when deleting a scene when "New Main Window" is open
3 changed files with 12 additions and 8 deletions

View File

@ -29,10 +29,7 @@ struct Scene *ED_scene_add(struct Main *bmain,
struct bContext *C,
struct wmWindow *win,
enum eSceneCopyMethod method) ATTR_NONNULL();
bool ED_scene_delete(struct bContext *C,
struct Main *bmain,
struct wmWindow *win,
struct Scene *scene) ATTR_NONNULL();
bool ED_scene_delete(struct bContext *C, struct Main *bmain, struct Scene *scene) ATTR_NONNULL();
void ED_scene_change_update(struct Main *bmain, struct Scene *scene, struct ViewLayer *layer)
ATTR_NONNULL();
bool ED_scene_view_layer_delete(struct Main *bmain,

View File

@ -86,7 +86,7 @@ Scene *ED_scene_add(Main *bmain, bContext *C, wmWindow *win, eSceneCopyMethod me
* \note Only call outside of area/region loops
* \return true if successful
*/
bool ED_scene_delete(bContext *C, Main *bmain, wmWindow *win, Scene *scene)
bool ED_scene_delete(bContext *C, Main *bmain, Scene *scene)
{
Scene *scene_new;
@ -104,7 +104,14 @@ bool ED_scene_delete(bContext *C, Main *bmain, wmWindow *win, Scene *scene)
return false;
}
WM_window_set_active_scene(bmain, C, win, scene_new);
for (wmWindow *win = wm->windows.first; win; win = win->next) {
if (win->parent != NULL) { /* We only care about main windows here... */
continue;
}
if (win->scene == scene) {
WM_window_set_active_scene(bmain, C, win, scene_new);
}
}
BKE_id_delete(bmain, scene);
@ -244,7 +251,7 @@ static int scene_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
if (ED_scene_delete(C, CTX_data_main(C), CTX_wm_window(C), scene) == false) {
if (ED_scene_delete(C, CTX_data_main(C), scene) == false) {
return OPERATOR_CANCELLED;
}

View File

@ -399,7 +399,7 @@ static bool scene_cb(bContext *C,
Scene *scene = (Scene *)tselem->id;
if (event == OL_SCENE_OP_DELETE) {
if (ED_scene_delete(C, CTX_data_main(C), CTX_wm_window(C), scene)) {
if (ED_scene_delete(C, CTX_data_main(C), scene)) {
WM_event_add_notifier(C, NC_SCENE | NA_REMOVED, scene);
}
else {