From 9509e18564452c1f95a8967accbb1aeb6094d222 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 28 Jan 2021 18:24:57 +1100 Subject: Fix T82785: Setting Image.alpha_mode clears generated image data --- source/blender/makesrna/intern/rna_image.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 1e84ded6cde..b3272f44826 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -128,6 +128,17 @@ static void rna_Image_colormanage_update(Main *bmain, Scene *UNUSED(scene), Poin WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id); } +static void rna_Image_alpha_mode_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Image *ima = (Image *)ptr->owner_id; + /* When operating on a generated image, avoid re-generating when changing the alpha-mode + * as it doesn't impact generated images, causing them to reload pixel data, see T82785. */ + if (ima->source == IMA_SRC_GENERATED) { + return; + } + rna_Image_colormanage_update(bmain, scene, ptr); +} + static void rna_Image_views_format_update(Main *bmain, Scene *scene, PointerRNA *ptr) { Image *ima = (Image *)ptr->owner_id; @@ -1133,7 +1144,7 @@ static void rna_def_image(BlenderRNA *brna) "Alpha Mode", "Representation of alpha in the image file, to convert to and from " "when saving and loading the image"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_colormanage_update"); + RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_alpha_mode_update"); prop = RNA_def_property(srna, "use_half_precision", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMA_HIGH_BITDEPTH); -- cgit v1.2.3