From 2939251a05c29b6462065394714a79195d067029 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 15 Mar 2021 16:26:57 +1100 Subject: Fix regression with modal operator file load check As of 2cc5af9c553cfc00b7d4616445ad954597a92d94, checking the window managers pointer for changes is no longer a valid way to check a file has been loaded. --- source/blender/windowmanager/intern/wm_event_system.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source/blender/windowmanager/intern') diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 39651db54f0..ed1b53e8e20 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2063,6 +2063,7 @@ static int wm_handler_operator_call(bContext *C, else if (ot->modal) { /* We set context to where modal handler came from. */ wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *win = CTX_wm_window(C); ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); @@ -2080,22 +2081,21 @@ static int wm_handler_operator_call(bContext *C, retval = ot->modal(C, op, event); OPERATOR_RETVAL_CHECK(retval); - /* When this is _not_ the case the modal modifier may have loaded - * a new blend file (demo mode does this), so we have to assume - * the event, operator etc have all been freed. - campbell */ - if (CTX_wm_manager(C) == wm) { + if (ot->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) { + wm->op_undo_depth--; + } - wm_event_modalkeymap_end(event, &event_backup); + /* When the window changes the the modal modifier may have loaded a new blend file + * (the `system_demo_mode` add-on does this), so we have to assume the event, + * operator, area, region etc have all been freed. */ + if ((CTX_wm_window(C) == win)) { - if (ot->flag & OPTYPE_UNDO) { - wm->op_undo_depth--; - } + wm_event_modalkeymap_end(event, &event_backup); if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) { wm_operator_reports(C, op, retval, false); if (op->type->modalkeymap) { - wmWindow *win = CTX_wm_window(C); WM_window_status_area_tag_redraw(win); } } -- cgit v1.2.3