Commit: 9509e18564452c1f95a8967accbb1aeb6094d222
Author: Campbell Barton
Date:   Thu Jan 28 18:24:57 2021 +1100
Branches: blender-v2.92-release
https://developer.blender.org/rB9509e18564452c1f95a8967accbb1aeb6094d222

Fix T82785: Setting Image.alpha_mode clears generated image data

===================================================================

M       source/blender/makesrna/intern/rna_image.c

===================================================================

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);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to