Fix T60905: Crash using smooth tool

Tools were relying on gizmos drawing to initialize their gizmos,
now tool gizmos are initialized immediately.
This commit is contained in:
Campbell Barton 2019-02-15 13:32:31 +11:00
parent 796abc90a8
commit 90f6fd0a36
Notes: blender-bot 2023-02-14 06:00:46 +01:00
Referenced by issue #62453, Keyframe values get reset while setting keyframes
Referenced by issue #61692, SHIFT no do work on blender when I assign it to a key on a tablet
Referenced by issue #61574, Eevee dynamic paint auto refresh
Referenced by issue #60905, Crash when using Smooth Tool
5 changed files with 15 additions and 7 deletions

View File

@ -233,6 +233,9 @@ struct wmKeyMap *WM_gizmogroup_keymap_common(
struct wmKeyMap *WM_gizmogroup_keymap_common_select(
const struct wmGizmoGroupType *gzgt, struct wmKeyConfig *config);
void WM_gizmogroup_ensure_init(
const struct bContext *C, struct wmGizmoGroup *gzgroup);
/* Sort utilities for use with 'BLI_listbase_sort'. */
int WM_gizmo_cmp_temp_fl(const void *gz_a_ptr, const void *gz_b_ptr);
int WM_gizmo_cmp_temp_fl_reverse(const void *gz_a_ptr, const void *gz_b_ptr);
@ -292,7 +295,7 @@ 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(
wmGizmoGroup *WM_gizmomaptype_group_init_runtime_with_region(
struct wmGizmoMapType *gzmap_type,
struct wmGizmoGroupType *gzgt, struct ARegion *ar);
void WM_gizmomaptype_group_unlink(

View File

@ -190,7 +190,7 @@ void wm_gizmogroup_intersectable_gizmos_to_list(const wmGizmoGroup *gzgroup, Lis
}
}
void wm_gizmogroup_ensure_initialized(wmGizmoGroup *gzgroup, const bContext *C)
void WM_gizmogroup_ensure_init(const bContext *C, wmGizmoGroup *gzgroup)
{
/* prepare for first draw */
if (UNLIKELY((gzgroup->init_flag & WM_GIZMOGROUP_INIT_SETUP) == 0)) {
@ -806,7 +806,7 @@ void WM_gizmomaptype_group_init_runtime(
}
}
void WM_gizmomaptype_group_init_runtime_with_region(
wmGizmoGroup *WM_gizmomaptype_group_init_runtime_with_region(
wmGizmoMapType *gzmap_type,
wmGizmoGroupType *gzgt, ARegion *ar)
{
@ -814,10 +814,13 @@ void WM_gizmomaptype_group_init_runtime_with_region(
BLI_assert(gzmap && gzmap->type == gzmap_type);
UNUSED_VARS_NDEBUG(gzmap_type);
wm_gizmogroup_new_from_type(gzmap, gzgt);
wmGizmoGroup *gzgroup = wm_gizmogroup_new_from_type(gzmap, gzgt);
wm_gizmomap_highlight_set(gzmap, NULL, NULL, 0);
ED_region_tag_redraw(ar);
return gzgroup;
}
/**

View File

@ -67,7 +67,6 @@ struct wmGizmo *wm_gizmogroup_find_intersected_gizmo(
int *r_part);
void wm_gizmogroup_intersectable_gizmos_to_list(
const struct wmGizmoGroup *gzgroup, struct ListBase *listbase);
void wm_gizmogroup_ensure_initialized(struct wmGizmoGroup *gzgroup, const struct bContext *C);
bool wm_gizmogroup_is_visible_in_drawstep(
const struct wmGizmoGroup *gzgroup, const eWM_GizmoFlagMapDrawStep drawstep);

View File

@ -355,7 +355,7 @@ static void gizmomap_prepare_drawing(
gzgroup->init_flag &= ~WM_GIZMOGROUP_INIT_REFRESH;
}
/* Calls `setup`, `setup_keymap` and `refresh` if they're defined. */
wm_gizmogroup_ensure_initialized(gzgroup, C);
WM_gizmogroup_ensure_init(C, gzgroup);
/* prepare drawing */
if (gzgroup->type->draw_prepare) {

View File

@ -2071,7 +2071,10 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
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);
wmGizmoGroup *gzgroup = WM_gizmomaptype_group_init_runtime_with_region(gzmap_type, gzgt, ar);
/* We can't rely on drawing to initialize gizmo's since disabling
* overlays/gizmos will prevent pre-drawing setup calls. (see T60905) */
WM_gizmogroup_ensure_init(C, gzgroup);
}
}
}