Fix #115140: Crash undoing painting on linked image from 3DView #115263

Merged
Philipp Oeser merged 1 commits from lichtwerk/blender:115140 into main 2023-11-28 12:05:17 +01:00
2 changed files with 16 additions and 4 deletions

View File

@ -274,6 +274,11 @@ class TEXTURE_UL_texpaintslots(UIList):
def draw_item(self, _context, layout, _data, item, _icon, _active_data, _active_propname, _index):
# mat = data
# Hint that painting on linked images is prohibited
ima = _data.texture_paint_images.get(item.name)
if ima is not None and ima.library is not None:
layout.enabled = False
if self.layout_type in {'DEFAULT', 'COMPACT'}:
layout.label(text=item.name, icon_value=item.icon_value)
elif self.layout_type == 'GRID':

View File

@ -4375,6 +4375,13 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
slot_last = slot;
}
/* Don't allow painting on linked images. */
if (slot->ima != nullptr && (ID_IS_LINKED(slot->ima) || ID_IS_OVERRIDE_LIBRARY(slot->ima)))
{
skip_tri = true;
tpage = nullptr;
}
/* Don't allow using the same image for painting and stenciling. */
if (slot->ima == ps->stencil_ima) {
/* Delay continuing the loop until after loop_uvs and bleed faces are initialized.
@ -6396,7 +6403,7 @@ void ED_paint_data_warning(ReportList *reports, bool uvs, bool mat, bool tex, bo
"Missing%s%s%s%s detected!",
!uvs ? TIP_(" UVs,") : "",
!mat ? TIP_(" Materials,") : "",
!tex ? TIP_(" Textures,") : "",
!tex ? TIP_(" Textures (or linked),") : "",
!stencil ? TIP_(" Stencil,") : "");
}
@ -6437,9 +6444,9 @@ bool ED_paint_proj_mesh_data_check(
BKE_texpaint_slot_refresh_cache(scene, ma, ob);
}
if (ma->texpaintslot != nullptr &&
(ma->texpaintslot[ma->paint_active_slot].ima == nullptr ||
Review

Indeed, logic here was utterly broken :(

Indeed, logic here was utterly broken :(
!ID_IS_LINKED(ma->texpaintslot[ma->paint_active_slot].ima) ||
!ID_IS_OVERRIDE_LIBRARY(ma->texpaintslot[ma->paint_active_slot].ima)))
ma->texpaintslot[ma->paint_active_slot].ima != nullptr &&
!ID_IS_LINKED(ma->texpaintslot[ma->paint_active_slot].ima) &&
!ID_IS_OVERRIDE_LIBRARY(ma->texpaintslot[ma->paint_active_slot].ima))
{
hastex = true;
break;