Fix paint cursor crash

The new paint cursor (introduced in rBe0c792135adf) could crash for 2d
painting without an active object.

Note there are still drawing asserts (because we are mixing 2d and 3d
drawing in 'paint_draw_cursor'), but these will be handled in a seperate
commit.

part of T69957

Reviewers: jbakker

Maniphest Tasks: T69957

Differential Revision: https://developer.blender.org/D5820
This commit is contained in:
Philipp Oeser 2019-09-17 14:41:18 +02:00
parent 3a08153d7a
commit 41d6d1463f
Notes: blender-bot 2023-11-20 12:14:32 +01:00
Referenced by issue #69948, Crash when switching to image painting
1 changed files with 3 additions and 2 deletions

View File

@ -1263,7 +1263,8 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
/* TODO: as sculpt and other paint modes are unified, this
* special mode of drawing will go away */
if ((mode == PAINT_MODE_SCULPT) && vc.obact->sculpt) {
Object *obact = vc.obact;
if ((mode == PAINT_MODE_SCULPT) && obact && obact->sculpt) {
float location[3];
int pixel_radius;
@ -1318,7 +1319,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
/* Only sculpt mode cursor for now */
/* Disable for PBVH_GRIDS */
SculptSession *ss = vc.obact->sculpt;
SculptSession *ss = obact ? obact->sculpt : NULL;
bool is_multires = ss && ss->pbvh && BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS;
if ((mode == PAINT_MODE_SCULPT) && ss && !is_multires &&