Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-03-07 13:47:00 +0300
committerCampbell Barton <campbell@blender.org>2022-03-07 13:47:00 +0300
commit0e51defcf42e1cb231d36da9ecc2cc0fbe6ae505 (patch)
tree237d73cf446d500bd7e7948f4c55c7b43bc5f181 /source/blender/editors/space_view3d/view3d_gizmo_ruler.c
parent72e20785e1e2ed7b15a9765ebb6df646fd32dbff (diff)
Fix T95591: Crash on drawing with measure tool with tweak fallback tool
Using press to activate the Tweak tool doesn't work well when used a fallback tool as the drag event is often used by the current tool - making it impossible not to select when dragging (unless the fallback tool is disabled entirely). Resolve this by using CLICK events when the Tweak tool is used as a fallback. Even though this avoids the crash, check for null-pointer de-reference since changes to the key-map shouldn't cause operators to crash. Note that the ability for operators to access a gizmo before it's fully initialized is a more general problem that should be addressed, but out of scope for a bug-fix. Reviewed By: zeddb, JulienKaspar, Severin Maniphest Tasks: T95591 Ref D14231
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_gizmo_ruler.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_ruler.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
index 1082483dcd7..adcb101bca9 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
@@ -469,6 +469,19 @@ static bool view3d_ruler_item_mousemove(const bContext *C,
return false;
}
+/**
+ * When the gizmo-group has been created immediately before running an operator
+ * to manipulate rulers, 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;
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -1308,6 +1321,10 @@ static int view3d_ruler_add_invoke(bContext *C, wmOperator *op, const wmEvent *e
wmGizmoGroup *gzgroup = WM_gizmomap_group_find(gzmap, view3d_gzgt_ruler_id);
const bool use_depth = (v3d->shading.type >= OB_SOLID);
+ if (!gizmo_ruler_check_for_operator(gzgroup)) {
+ return OPERATOR_CANCELLED;
+ }
+
/* Create new line */
RulerItem *ruler_item;
ruler_item = ruler_item_add(gzgroup);
@@ -1383,6 +1400,9 @@ static int view3d_ruler_remove_invoke(bContext *C, wmOperator *op, const wmEvent
wmGizmoMap *gzmap = region->gizmo_map;
wmGizmoGroup *gzgroup = WM_gizmomap_group_find(gzmap, view3d_gzgt_ruler_id);
if (gzgroup) {
+ if (!gizmo_ruler_check_for_operator(gzgroup)) {
+ return OPERATOR_CANCELLED;
+ }
RulerInfo *ruler_info = gzgroup->customdata;
if (ruler_info->item_active) {
RulerItem *ruler_item = ruler_info->item_active;