GPencil: Only brushes with pinned materials have materials

Using GP_BRUSH_MATERIAL_PINNED to switch between active material and brush material, instead of updating all brushes on active material changes. This will allow brushes to have no material and therefore to not inflate the user count.

This fix T62465.

Patch contributed by @matc
Reviewers: @brecht @antoniov @billreynish @mendio
This commit is contained in:
2019-03-25 17:02:42 +01:00
parent 84240ebb3e
commit 7021bd5273
23 changed files with 292 additions and 262 deletions

View File

@@ -2617,8 +2617,19 @@ static void lib_link_brush(FileData *fd, Main *main)
brush->paint_curve = newlibadr_us(fd, brush->id.lib, brush->paint_curve);
/* link default grease pencil palette */
if (brush->gpencil_settings != NULL) {
brush->gpencil_settings->material = newlibadr_us(fd, brush->id.lib, brush->gpencil_settings->material);
if (brush->gpencil_settings != NULL)
{
if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED)
{
brush->gpencil_settings->material = newlibadr_us(fd, brush->id.lib, brush->gpencil_settings->material);
if (!brush->gpencil_settings->material) {
brush->gpencil_settings->flag &= ~GP_BRUSH_MATERIAL_PINNED;
}
}
else {
brush->gpencil_settings->material = NULL;
}
}
brush->id.tag &= ~LIB_TAG_NEED_LINK;