Fix T59210: Measure tool crash w/o overlays/gizmos
authorCampbell Barton <ideasman42@gmail.com>
Tue, 11 Dec 2018 23:44:04 +0000 (10:44 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 11 Dec 2018 23:44:04 +0000 (10:44 +1100)
source/blender/editors/space_view3d/view3d_gizmo_ruler.c

index 5623681fec4cd3758679512edbfcad2184c0c87f..ed5a1ab7720d5cd9d906cdecdcd2f0a87fceea1a 100644 (file)
@@ -33,6 +33,7 @@
 #include "BKE_context.h"
 #include "BKE_gpencil.h"
 #include "BKE_main.h"
+#include "BKE_report.h"
 
 #include "BKE_object.h"
 #include "BKE_unit.h"
@@ -1037,12 +1038,19 @@ static bool view3d_ruler_poll(bContext *C)
        return true;
 }
 
-static int view3d_ruler_add_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
+static int view3d_ruler_add_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
        ARegion *ar = CTX_wm_region(C);
        View3D *v3d = CTX_wm_view3d(C);
        RegionView3D *rv3d = ar->regiondata;
 
+       if ((v3d->flag2 & V3D_RENDER_OVERRIDE) ||
+           (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)))
+       {
+               BKE_report(op->reports, RPT_WARNING, "Gizmos hidden in this view");
+               return OPERATOR_CANCELLED;
+       }
+
        wmGizmoMap *gzmap = ar->gizmo_map;
        wmGizmoGroup *gzgroup = WM_gizmomap_group_find(gzmap, view3d_gzgt_ruler_id);
        const bool use_depth = (v3d->shading.type >= OB_SOLID);