[Bf-blender-cvs] [815eebbe17a] topbar: Solve context issues when tweaking operator settings from top-bar
Julian Eisel
noreply at git.blender.org
Tue Oct 24 17:55:36 CEST 2017
Commit: 815eebbe17ab6328e0623bdab5bf995e9d5504e3
Author: Julian Eisel
Date: Tue Oct 24 17:26:35 2017 +0200
Branches: topbar
https://developer.blender.org/rB815eebbe17ab6328e0623bdab5bf995e9d5504e3
Solve context issues when tweaking operator settings from top-bar
E.g. editing settings after transforming in 3D View would print
warnings, or in Movie Clip Editor wouldn't work at all.
We now store the area & region an operator was executed in and restore
it temporarily when redoing.
Ideally operators wouldn't depend on screen context for event-less
execution (exec callback), but we're far from that.
===================================================================
M source/blender/editors/util/undo.c
M source/blender/makesdna/DNA_windowmanager_types.h
M source/blender/windowmanager/intern/wm.c
===================================================================
diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c
index 5b91ee4fc29..54cf994067c 100644
--- a/source/blender/editors/util/undo.c
+++ b/source/blender/editors/util/undo.c
@@ -402,14 +402,12 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
if (op) {
wmWindowManager *wm = CTX_wm_manager(C);
- struct Scene *scene = CTX_data_scene(C);
+ struct Scene *cur_scene = CTX_data_scene(C);
+ ScrArea *cur_area = CTX_wm_area(C);
+ ARegion *cur_region = CTX_wm_region(C);
- /* keep in sync with logic in view3d_panel_operator_redo() */
- ARegion *ar = CTX_wm_region(C);
- ARegion *ar1 = BKE_area_find_region_active_win(CTX_wm_area(C));
-
- if (ar1)
- CTX_wm_region_set(C, ar1);
+ CTX_wm_area_set(C, op->execution_area);
+ CTX_wm_region_set(C, op->execution_region);
if ((WM_operator_repeat_check(C, op)) &&
(WM_operator_poll(C, op->type)) &&
@@ -418,7 +416,7 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
* (which copy their data), wont stop redo, see [#29579]],
*
* note, - WM_operator_check_ui_enabled() jobs test _must_ stay in sync with this */
- (WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY) == 0))
+ (WM_jobs_test(wm, cur_scene, WM_JOB_TYPE_ANY) == 0))
{
int retval;
@@ -457,8 +455,8 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
}
}
- /* set region back */
- CTX_wm_region_set(C, ar);
+ CTX_wm_area_set(C, cur_area);
+ CTX_wm_region_set(C, cur_region);
}
else {
if (G.debug & G_DEBUG) {
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index ca9b4e1aba0..c14cbbb0772 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -371,6 +371,10 @@ typedef struct wmOperator {
struct uiLayout *layout; /* runtime for drawing */
short flag, pad[3];
+ /* Screen context the operator was finished in. It gets temporarily
+ * restored during operator repeat. Only set for registered operators. */
+ struct ScrArea *execution_area;
+ struct ARegion *execution_region;
} wmOperator;
/* operator type return flags: exec(), invoke() modal(), return values */
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index 05ee9957723..3becd09a234 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -162,6 +162,9 @@ void wm_operator_register(bContext *C, wmOperator *op)
wmWindowManager *wm = CTX_wm_manager(C);
int tot = 0;
+ op->execution_area = CTX_wm_area(C);
+ op->execution_region = CTX_wm_region(C);
+
BLI_addtail(&wm->operators, op);
/* only count registered operators */
More information about the Bf-blender-cvs
mailing list