Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_gizmo_ruler.c
| Show First 20 Lines • Show All 463 Lines • ▼ Show 20 Lines | #ifdef USE_AXIS_CONSTRAINTS | ||||
| } | } | ||||
| #endif | #endif | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| /** | |||||
| * When the gizmo-group has been created immediately before adding/removing, | |||||
| * it's possible the new gizmo-group has not yet been initialized. | |||||
| * in 3.0 this happened because left-click drag would both select and add a new ruler, | |||||
| * significantly increasing the likelihood of this happening. | |||||
| * Workaround this crash by checking the gizmo's custom-data has not been cleared. | |||||
| * The key-map has also been modified not to trigger this bug, see T95591. | |||||
| */ | |||||
| static bool gizmo_ruler_check_for_operator(const wmGizmoGroup *gzgroup) | |||||
| { | |||||
| return gzgroup->customdata != NULL; | |||||
| } | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Ruler/Grease Pencil Conversion | /** \name Ruler/Grease Pencil Conversion | ||||
| * \{ */ | * \{ */ | ||||
| /* Helper: Find the layer created as ruler. */ | /* Helper: Find the layer created as ruler. */ | ||||
| static bGPDlayer *view3d_ruler_layer_get(bGPdata *gpd) | static bGPDlayer *view3d_ruler_layer_get(bGPdata *gpd) | ||||
| ▲ Show 20 Lines • Show All 823 Lines • ▼ Show 20 Lines | if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)) { | ||||
| BKE_report(op->reports, RPT_WARNING, "Gizmos hidden in this view"); | BKE_report(op->reports, RPT_WARNING, "Gizmos hidden in this view"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| wmGizmoMap *gzmap = region->gizmo_map; | wmGizmoMap *gzmap = region->gizmo_map; | ||||
| wmGizmoGroup *gzgroup = WM_gizmomap_group_find(gzmap, view3d_gzgt_ruler_id); | wmGizmoGroup *gzgroup = WM_gizmomap_group_find(gzmap, view3d_gzgt_ruler_id); | ||||
| const bool use_depth = (v3d->shading.type >= OB_SOLID); | const bool use_depth = (v3d->shading.type >= OB_SOLID); | ||||
| if (!gizmo_ruler_check_for_operator(gzgroup)) { | |||||
| return OPERATOR_CANCELLED; | |||||
| } | |||||
| /* Create new line */ | /* Create new line */ | ||||
| RulerItem *ruler_item; | RulerItem *ruler_item; | ||||
| ruler_item = ruler_item_add(gzgroup); | ruler_item = ruler_item_add(gzgroup); | ||||
| /* This is a little weak, but there is no real good way to tweak directly. */ | /* This is a little weak, but there is no real good way to tweak directly. */ | ||||
| WM_gizmo_highlight_set(gzmap, &ruler_item->gz); | WM_gizmo_highlight_set(gzmap, &ruler_item->gz); | ||||
| if (WM_operator_name_call(C, "GIZMOGROUP_OT_gizmo_tweak", WM_OP_INVOKE_REGION_WIN, NULL) == | if (WM_operator_name_call(C, "GIZMOGROUP_OT_gizmo_tweak", WM_OP_INVOKE_REGION_WIN, NULL) == | ||||
| OPERATOR_RUNNING_MODAL) { | OPERATOR_RUNNING_MODAL) { | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | static int view3d_ruler_remove_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)) { | if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)) { | ||||
| BKE_report(op->reports, RPT_WARNING, "Gizmos hidden in this view"); | BKE_report(op->reports, RPT_WARNING, "Gizmos hidden in this view"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| wmGizmoMap *gzmap = region->gizmo_map; | wmGizmoMap *gzmap = region->gizmo_map; | ||||
| wmGizmoGroup *gzgroup = WM_gizmomap_group_find(gzmap, view3d_gzgt_ruler_id); | wmGizmoGroup *gzgroup = WM_gizmomap_group_find(gzmap, view3d_gzgt_ruler_id); | ||||
| if (gzgroup) { | if (gzgroup) { | ||||
| if (!gizmo_ruler_check_for_operator(gzgroup)) { | |||||
| return OPERATOR_CANCELLED; | |||||
| } | |||||
| RulerInfo *ruler_info = gzgroup->customdata; | RulerInfo *ruler_info = gzgroup->customdata; | ||||
| if (ruler_info->item_active) { | if (ruler_info->item_active) { | ||||
| RulerItem *ruler_item = ruler_info->item_active; | RulerItem *ruler_item = ruler_info->item_active; | ||||
| if ((ruler_item->flag & RULERITEM_USE_ANGLE) && | if ((ruler_item->flag & RULERITEM_USE_ANGLE) && | ||||
| (ruler_item->flag & RULERITEM_USE_ANGLE_ACTIVE)) { | (ruler_item->flag & RULERITEM_USE_ANGLE_ACTIVE)) { | ||||
| ruler_item->flag &= ~(RULERITEM_USE_ANGLE | RULERITEM_USE_ANGLE_ACTIVE); | ruler_item->flag &= ~(RULERITEM_USE_ANGLE | RULERITEM_USE_ANGLE_ACTIVE); | ||||
| } | } | ||||
| else { | else { | ||||
| Show All 27 Lines | |||||