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-23 17:35:11 +0300
commit1c83354c63a334a57118579d653e642524f23fce (patch)
tree1f36a10a361c00f6f20c2d2bc8da1909a55c9244 /source/blender/blenloader/intern/versioning_300.c
parentc2a2f3553aed58ae9e4c165f8bfcad2b31dcf74b (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.
Diffstat (limited to 'source/blender/blenloader/intern/versioning_300.c')
-rw-r--r--source/blender/blenloader/intern/versioning_300.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index eac27bc57ed..844354c8bc3 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -46,6 +46,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"
@@ -1620,6 +1621,31 @@ static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre
}
}
+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)
{
@@ -3112,6 +3138,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.
*