Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2022-06-23 17:00:43 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-06-24 16:50:13 +0300
commit8ef0a0b2310091d9e72b1bcced98b51999d42707 (patch)
treec1057a47eeb4bf5c25ddd1a06432944a010fb8c8
parenta66bc632ab3d2d587796f1bb6032353963e396f5 (diff)
Fix T99028: crash deleting file output node with color management override
One case of copying image formats was not properly using BKE_image_format_copy. To fix this for existing .blend file we need to do versioning, ensuring the curve mapping is properly copied.
-rw-r--r--source/blender/blenloader/intern/versioning_300.c53
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_output_file.cc6
2 files changed, 57 insertions, 2 deletions
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index bafbb7712ab..48a536c5dc5 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -44,6 +44,7 @@
#include "BKE_asset.h"
#include "BKE_attribute.h"
#include "BKE_collection.h"
+#include "BKE_colortools.h"
#include "BKE_curve.h"
#include "BKE_data_transfer.h"
#include "BKE_deform.h"
@@ -1368,6 +1369,31 @@ static void version_liboverride_rnacollections_insertion_animdata(ID *id)
}
}
+static void version_fix_image_format_copy(Main *bmain, ImageFormatData *format)
+{
+ /* Fix bug where curves in image format were not properly copied to file output
+ * node, incorrectly sharing a pointer with the scene settings. Copy the data
+ * structure now as it should have been done in the first place. */
+ if (format->view_settings.curve_mapping) {
+ LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+ if (format != &scene->r.im_format && ELEM(format->view_settings.curve_mapping,
+ scene->view_settings.curve_mapping,
+ scene->r.im_format.view_settings.curve_mapping)) {
+ format->view_settings.curve_mapping = BKE_curvemapping_copy(
+ format->view_settings.curve_mapping);
+ break;
+ }
+ }
+
+ /* Remove any invalid curves with missing data. */
+ if (format->view_settings.curve_mapping->cm[0].curve == NULL) {
+ BKE_curvemapping_free(format->view_settings.curve_mapping);
+ format->view_settings.curve_mapping = NULL;
+ format->view_settings.flag &= ~COLORMANAGE_VIEW_USE_CURVES;
+ }
+ }
+}
+
/* NOLINTNEXTLINE: readability-function-size */
void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
@@ -2770,6 +2796,33 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!MAIN_VERSION_ATLEAST(bmain, 303, 4)) {
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_COMPOSIT) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
+ if (node->type == CMP_NODE_OUTPUT_FILE) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
+ if (sock->storage) {
+ NodeImageMultiFileSocket *sockdata = (NodeImageMultiFileSocket *)sock->storage;
+ version_fix_image_format_copy(bmain, &sockdata->format);
+ }
+ }
+
+ if (node->storage) {
+ NodeImageMultiFile *nimf = (NodeImageMultiFile *)node->storage;
+ version_fix_image_format_copy(bmain, &nimf->format);
+ }
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+
+ LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+ version_fix_image_format_copy(bmain, &scene->r.im_format);
+ }
+ }
+
/**
* Versioning code until next subversion bump goes here.
*
diff --git a/source/blender/nodes/composite/nodes/node_composite_output_file.cc b/source/blender/nodes/composite/nodes/node_composite_output_file.cc
index 1fd6e62b4c5..f1621f83ac3 100644
--- a/source/blender/nodes/composite/nodes/node_composite_output_file.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_output_file.cc
@@ -130,7 +130,8 @@ bNodeSocket *ntreeCompositOutputFileAddSocket(bNodeTree *ntree,
ntreeCompositOutputFileUniqueLayer(&node->inputs, sock, name, '_');
if (im_format) {
- sockdata->format = *im_format;
+ BKE_image_format_copy(&sockdata->format, im_format);
+ sockdata->format.color_management = R_IMF_COLOR_MANAGEMENT_FOLLOW_SCENE;
if (BKE_imtype_is_movie(sockdata->format.imtype)) {
sockdata->format.imtype = R_IMF_IMTYPE_OPENEXR;
}
@@ -198,7 +199,8 @@ static void init_output_file(const bContext *C, PointerRNA *ptr)
RenderData *rd = &scene->r;
BLI_strncpy(nimf->base_path, rd->pic, sizeof(nimf->base_path));
- nimf->format = rd->im_format;
+ BKE_image_format_copy(&nimf->format, &rd->im_format);
+ nimf->format.color_management = R_IMF_COLOR_MANAGEMENT_FOLLOW_SCENE;
if (BKE_imtype_is_movie(nimf->format.imtype)) {
nimf->format.imtype = R_IMF_IMTYPE_OPENEXR;
}