From a57d9f725f6e4c565163acb1e57f5417a665c9dd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 29 Jan 2016 15:03:49 +1100 Subject: Fix crash running transform in background mode --- source/blender/editors/transform/transform_input.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source/blender/editors/transform/transform_input.c') diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index f55127fd4ec..9b7d19eacd5 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -88,9 +88,10 @@ static void InputTrackBall(TransInfo *UNUSED(t), MouseInput *mi, const double mv static void InputHorizontalRatio(TransInfo *t, MouseInput *UNUSED(mi), const double mval[2], float output[3]) { - const double pad = t->ar->winx / 10; + const int winx = t->ar ? t->ar->winx : 1; + const double pad = winx / 10; - output[0] = (mval[0] - pad) / (t->ar->winx - 2 * pad); + output[0] = (mval[0] - pad) / (winx - 2 * pad); } static void InputHorizontalAbsolute(TransInfo *t, MouseInput *mi, const double mval[2], float output[3]) @@ -105,9 +106,10 @@ static void InputHorizontalAbsolute(TransInfo *t, MouseInput *mi, const double m static void InputVerticalRatio(TransInfo *t, MouseInput *UNUSED(mi), const double mval[2], float output[3]) { - const double pad = t->ar->winy / 10; + const int winy = t->ar ? t->ar->winy : 1; + const double pad = winy / 10; - output[0] = (mval[1] - pad) / (t->ar->winy - 2 * pad); + output[0] = (mval[1] - pad) / (winy - 2 * pad); } static void InputVerticalAbsolute(TransInfo *t, MouseInput *mi, const double mval[2], float output[3]) -- cgit v1.2.3