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.
This commit is contained in:
parent
a66bc632ab
commit
8ef0a0b231
Notes:
blender-bot
2023-02-14 08:28:46 +01:00
Referenced by issue #99028, Crash on Removing File Output Node when Color Management Referenced by issue #98661, 3.2: Potential candidates for corrective releases
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue