Fix #131711: Grease Pencil: Null check when getting material passes
The material returned by `BKE_object_material_get` could be nullptr when the material is somehow not a grease pencil material and this situation needs to be handled. This is likely caused by faulty file from previous verisons. Pull Request: https://projects.blender.org/blender/blender/pulls/131714
This commit is contained in:
@@ -190,12 +190,13 @@ void draw_custom_curve_settings(const bContext * /*C*/, uiLayout *layout, Pointe
|
||||
static Vector<int> get_grease_pencil_material_passes(const Object *ob)
|
||||
{
|
||||
short *totcol = BKE_object_material_len_p(const_cast<Object *>(ob));
|
||||
Vector<int> result(*totcol);
|
||||
Vector<int> result(*totcol, 0);
|
||||
Material *ma = nullptr;
|
||||
for (short i = 0; i < *totcol; i++) {
|
||||
ma = BKE_object_material_get(const_cast<Object *>(ob), i + 1);
|
||||
/* Pass index of the grease pencil material. */
|
||||
result[i] = ma->gp_style->index;
|
||||
if (ma = BKE_object_material_get(const_cast<Object *>(ob), i + 1)) {
|
||||
/* Pass index of the grease pencil material. */
|
||||
result[i] = ma->gp_style->index;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user