Fix T60112: Smooth crashes w/ multiple views

This commit is contained in:
Campbell Barton 2019-01-22 16:51:31 +11:00
parent a93cbb70cd
commit ee3c177dd3
Notes: blender-bot 2023-03-24 17:05:22 +01:00
Referenced by issue #60112, Smoothing crash with multiple views
3 changed files with 27 additions and 6 deletions

View File

@ -297,6 +297,9 @@ void WM_gizmomaptype_group_init_runtime_keymap(
void WM_gizmomaptype_group_init_runtime(
const struct Main *bmain, struct wmGizmoMapType *gzmap_type,
struct wmGizmoGroupType *gzgt);
void WM_gizmomaptype_group_init_runtime_with_region(
struct wmGizmoMapType *gzmap_type,
struct wmGizmoGroupType *gzgt, struct ARegion *ar);
void WM_gizmomaptype_group_unlink(
struct bContext *C, struct Main *bmain, struct wmGizmoMapType *gzmap_type,
const struct wmGizmoGroupType *gzgt);

View File

@ -792,6 +792,11 @@ void WM_gizmomaptype_group_init_runtime(
const Main *bmain, wmGizmoMapType *gzmap_type,
wmGizmoGroupType *gzgt)
{
/* Tools add themselves. */
if (gzgt->flag & WM_GIZMOGROUPTYPE_TOOL_INIT) {
return;
}
/* now create a gizmo for all existing areas */
for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) {
for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
@ -800,11 +805,7 @@ void WM_gizmomaptype_group_init_runtime(
for (ARegion *ar = lb->first; ar; ar = ar->next) {
wmGizmoMap *gzmap = ar->gizmo_map;
if (gzmap && gzmap->type == gzmap_type) {
wm_gizmogroup_new_from_type(gzmap, gzgt);
/* just add here, drawing will occur on next update */
wm_gizmomap_highlight_set(gzmap, NULL, NULL, 0);
ED_region_tag_redraw(ar);
WM_gizmomaptype_group_init_runtime_with_region(gzmap_type, gzgt, ar);
}
}
}
@ -812,6 +813,18 @@ void WM_gizmomaptype_group_init_runtime(
}
}
void WM_gizmomaptype_group_init_runtime_with_region(
wmGizmoMapType *gzmap_type,
wmGizmoGroupType *gzgt, ARegion *ar)
{
wmGizmoMap *gzmap = ar->gizmo_map;
BLI_assert(gzmap && gzmap->type == gzmap_type);
wm_gizmogroup_new_from_type(gzmap, gzgt);
wm_gizmomap_highlight_set(gzmap, NULL, NULL, 0);
ED_region_tag_redraw(ar);
}
/**
* Unlike #WM_gizmomaptype_group_unlink this doesn't maintain correct state, simply free.

View File

@ -2057,7 +2057,12 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
if (gzgt != NULL) {
if ((gzgt->flag & WM_GIZMOGROUPTYPE_TOOL_INIT) != 0) {
WM_gizmo_group_type_ensure_ptr(gzgt);
ARegion *ar = CTX_wm_region(C);
if (ar != NULL) {
wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params);
WM_gizmo_group_type_ensure_ptr_ex(gzgt, gzmap_type);
WM_gizmomaptype_group_init_runtime_with_region(gzmap_type, gzgt, ar);
}
}
}
}