Fix T47188: Blender crashes when trying to undo adding new scene with "copy settings".

Our RenderSettings struct may have a bit too much levels, makes it hard to track
all 'pointer' data during copy...

Fixed several issues here, but not sure I found all existing ones. :/
This commit is contained in:
2016-01-16 12:44:55 +01:00
parent 36aa7e659e
commit 2c5bc023c2

View File

@@ -170,6 +170,7 @@ Scene *BKE_scene_copy(Scene *sce, int type)
rl = scen->r.layers;
rv = scen->r.views;
curvemapping_free_data(&scen->r.mblur_shutter_curve);
scen->r = sce->r;
scen->r.layers = rl;
scen->r.actlay = 0;
@@ -183,6 +184,7 @@ Scene *BKE_scene_copy(Scene *sce, int type)
scen->id.properties = IDP_CopyProperty(sce->id.properties);
MEM_freeN(scen->toolsettings);
BKE_sound_destroy_scene(scen);
}
else {
scen = BKE_libblock_copy(&sce->id);
@@ -192,7 +194,7 @@ Scene *BKE_scene_copy(Scene *sce, int type)
id_us_plus((ID *)scen->world);
id_us_plus((ID *)scen->set);
id_us_plus((ID *)scen->gm.dome.warptext);
/* id_us_plus((ID *)scen->gm.dome.warptext); */ /* XXX Not refcounted? see readfile.c */
scen->ed = NULL;
scen->theDag = NULL;
@@ -226,14 +228,6 @@ Scene *BKE_scene_copy(Scene *sce, int type)
base = base->next;
}
/* copy color management settings */
BKE_color_managed_display_settings_copy(&scen->display_settings, &sce->display_settings);
BKE_color_managed_view_settings_copy(&scen->view_settings, &sce->view_settings);
BKE_color_managed_view_settings_copy(&scen->r.im_format.view_settings, &sce->r.im_format.view_settings);
BLI_strncpy(scen->sequencer_colorspace_settings.name, sce->sequencer_colorspace_settings.name,
sizeof(scen->sequencer_colorspace_settings.name));
/* copy action and remove animation used by sequencer */
BKE_animdata_copy_id_action(&scen->id);
@@ -254,10 +248,21 @@ Scene *BKE_scene_copy(Scene *sce, int type)
}
new_srl = new_srl->next;
}
curvemapping_copy_data(&scen->r.mblur_shutter_curve, &sce->r.mblur_shutter_curve);
}
/* copy color management settings */
BKE_color_managed_display_settings_copy(&scen->display_settings, &sce->display_settings);
BKE_color_managed_view_settings_copy(&scen->view_settings, &sce->view_settings);
BKE_color_managed_colorspace_settings_copy(&scen->sequencer_colorspace_settings, &sce->sequencer_colorspace_settings);
BKE_color_managed_display_settings_copy(&scen->r.im_format.display_settings, &sce->r.im_format.display_settings);
BKE_color_managed_view_settings_copy(&scen->r.im_format.view_settings, &sce->r.im_format.view_settings);
BKE_color_managed_display_settings_copy(&scen->r.bake.im_format.display_settings, &sce->r.bake.im_format.display_settings);
BKE_color_managed_view_settings_copy(&scen->r.bake.im_format.view_settings, &sce->r.bake.im_format.view_settings);
curvemapping_copy_data(&scen->r.mblur_shutter_curve, &sce->r.mblur_shutter_curve);
/* tool settings */
scen->toolsettings = MEM_dupallocN(sce->toolsettings);