Fix T79373: Forbid painting on linked image from 3DView.

As noted by @lichtwerk (thanks), one can have a local object and/or
material using a linked image data-block, this case needs some different
handling to prevent painting on such linked image.

For now, tweak `BKE_paint_proj_mesh_data_check` (eeeek, that name
prefix!) to consider paintslots with linked image as 'non-existing'.
This commit is contained in:
Bastien Montagne 2020-09-21 14:24:55 +02:00
parent 154752243d
commit 82aa300e1c
Notes: blender-bot 2023-11-28 12:06:28 +01:00
Referenced by issue #79373, Crash undo painting on linked image
Referenced by pull request #115263, Fix #115140: Crash undoing painting on linked image from 3DView
Referenced by commit a4b8d214c6, Fix #115140: Crash undoing painting on linked image from 3DView
1 changed files with 6 additions and 10 deletions

View File

@ -6333,19 +6333,15 @@ bool BKE_paint_proj_mesh_data_check(
for (int i = 1; i < ob->totcol + 1; i++) {
Material *ma = BKE_object_material_get(ob, i);
if (ma) {
if (ma && !ID_IS_LINKED(ma)) {
hasmat = true;
if (!ma->texpaintslot) {
if (ma->texpaintslot == NULL) {
/* refresh here just in case */
BKE_texpaint_slot_refresh_cache(scene, ma);
/* if still no slots, we have to add */
if (ma->texpaintslot) {
hastex = true;
break;
}
}
else {
if (ma->texpaintslot != NULL &&
(ma->texpaintslot[ma->paint_active_slot].ima == NULL ||
!ID_IS_LINKED(ma->texpaintslot[ma->paint_active_slot].ima))) {
hastex = true;
break;
}
@ -6354,7 +6350,7 @@ bool BKE_paint_proj_mesh_data_check(
}
}
else if (imapaint->mode == IMAGEPAINT_MODE_IMAGE) {
if (imapaint->canvas == NULL) {
if (imapaint->canvas == NULL || ID_IS_LINKED(imapaint->canvas)) {
hastex = false;
}
}