diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-21 12:11:47 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-21 12:11:47 +0400 |
commit | e4a2df9fec4859609106179715af54eed608a29f (patch) | |
tree | d5d8302b5d7ad2fa69c229a0f18fcc1d90e78427 /source/blender/editors/space_graph | |
parent | 9ae0e585b0aab466c978ec1a55c824d902faa3b4 (diff) |
View2d: check UI_view2d_view_to_region_clip succeeds before using the result
Diffstat (limited to 'source/blender/editors/space_graph')
-rw-r--r-- | source/blender/editors/space_graph/graph_select.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 08f561726d9..2e0e2b1a0d1 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -1048,16 +1048,14 @@ static void nearest_fcurve_vert_store( * needed to access the relevant vertex coordinates in the 3x3 * 'vec' matrix */ - UI_view2d_view_to_region_clip(v2d, - bezt->vec[hpoint + 1][0], bezt->vec[hpoint + 1][1] * unit_scale, - &screen_co[0], &screen_co[1]); - - /* check if distance from mouse cursor to vert in screen space is within tolerance */ - dist = len_v2v2_int(mval, screen_co); - - if (dist <= GVERTSEL_TOL) { + if (UI_view2d_view_to_region_clip(v2d, + bezt->vec[hpoint + 1][0], bezt->vec[hpoint + 1][1] * unit_scale, + &screen_co[0], &screen_co[1]) && + /* check if distance from mouse cursor to vert in screen space is within tolerance */ + ((dist = len_v2v2_int(mval, screen_co)) <= GVERTSEL_TOL)) + { tNearestVertInfo *nvi = (tNearestVertInfo *)matches->last; - short replace = 0; + bool replace = false; /* if there is already a point for the F-Curve, check if this point is closer than that was */ if ((nvi) && (nvi->fcu == fcu)) { |