diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-13 21:25:03 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-13 21:25:03 +0400 |
commit | be513d1b15630b629d09a6fdfa6ada808586a9dc (patch) | |
tree | 04e41990bcdb34d645ed14c073e4e31aa5670937 /source | |
parent | 7a3b44cf69b009fc77ffc361f5500e20131faa59 (diff) |
fix for missing NULL checks when sequence-strip pointers become NULL because of problems with library linking.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/mask.c | 71 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 6 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 18 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_sequence_types.h | 14 |
4 files changed, 93 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index 4b4dcff229d..3c46e7bcd47 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -40,18 +40,22 @@ #include "BLI_math.h" #include "DNA_mask_types.h" +#include "DNA_node_types.h" #include "DNA_scene_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" #include "DNA_movieclip_types.h" #include "DNA_tracking_types.h" +#include "DNA_sequence_types.h" #include "BKE_curve.h" #include "BKE_global.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_mask.h" +#include "BKE_node.h" +#include "BKE_sequencer.h" #include "BKE_tracking.h" #include "BKE_movieclip.h" #include "BKE_utildefines.h" @@ -1561,26 +1565,83 @@ void BKE_mask_free(Mask *mask) BKE_mask_layer_free_list(&mask->masklayers); } + +static void ntree_unlink_mask_cb(void *calldata, struct ID *UNUSED(owner_id), struct bNodeTree *ntree) +{ + ID *id = (ID *)calldata; + bNode *node; + + for (node = ntree->nodes.first; node; node = node->next) { + if (node->id == id) { + node->id = NULL; + } + } +} + void BKE_mask_unlink(Main *bmain, Mask *mask) { bScreen *scr; ScrArea *area; SpaceLink *sl; + Scene *scene; for (scr = bmain->screen.first; scr; scr = scr->id.next) { for (area = scr->areabase.first; area; area = area->next) { for (sl = area->spacedata.first; sl; sl = sl->next) { - if (sl->spacetype == SPACE_CLIP) { - SpaceClip *sc = (SpaceClip *) sl; + switch (sl->spacetype) { + case SPACE_CLIP: + { + SpaceClip *sc = (SpaceClip *)sl; - if (sc->mask_info.mask == mask) - sc->mask_info.mask = NULL; + if (sc->mask_info.mask == mask) { + sc->mask_info.mask = NULL; + } + break; + } + case SPACE_IMAGE: + { + SpaceImage *sima = (SpaceImage *)sl; + + if (sima->mask_info.mask == mask) { + sima->mask_info.mask = NULL; + } + break; + } } } } } - mask->id.us = 0; + for (scene = bmain->scene.first; scene; scene = scene->id.next) { + if (scene->ed) { + Sequence *seq; + + SEQ_BEGIN (scene->ed, seq) + { + if (seq->mask == mask) { + seq->mask = NULL; + } + } + SEQ_END + } + + + if (scene->nodetree) { + bNode *node; + for (node = scene->nodetree->nodes.first; node; node = node->next) { + if (node->id == &mask->id) { + node->id = NULL; + } + } + } + } + + { + bNodeTreeType *treetype = ntreeGetType(NTREE_COMPOSIT); + treetype->foreach_nodetree(bmain, (void *)mask, &ntree_unlink_mask_cb); + } + + BKE_libblock_free(&bmain->mask, mask); } void BKE_mask_coord_from_frame(float r_co[2], const float co[2], const float frame_size[2]) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 0432e7a62a2..528b9dff164 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -594,6 +594,9 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, int lock_range) } break; case SEQ_TYPE_MOVIECLIP: + if (seq->clip == NULL) + return; + seq->len = BKE_movieclip_get_duration(seq->clip); seq->len -= seq->anim_startofs; @@ -603,8 +606,9 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, int lock_range) } break; case SEQ_TYPE_MASK: + if (seq->mask == NULL) + return; seq->len = BKE_mask_get_duration(seq->mask); - seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; if (seq->len < 0) { diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 74decee6c25..e7722e07442 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4842,19 +4842,27 @@ static void lib_link_scene(FileData *fd, Main *main) } if (seq->clip) { seq->clip = newlibadr(fd, sce->id.lib, seq->clip); - seq->clip->id.us++; + if (seq->clip) { + seq->clip->id.us++; + } } if (seq->mask) { seq->mask = newlibadr(fd, sce->id.lib, seq->mask); - seq->mask->id.us++; + if (seq->mask) { + seq->mask->id.us++; + } + } + if (seq->scene_camera) { + seq->scene_camera = newlibadr(fd, sce->id.lib, seq->scene_camera); } - if (seq->scene_camera) seq->scene_camera = newlibadr(fd, sce->id.lib, seq->scene_camera); if (seq->sound) { seq->scene_sound = NULL; - if (seq->type == SEQ_TYPE_SOUND_HD) + if (seq->type == SEQ_TYPE_SOUND_HD) { seq->type = SEQ_TYPE_SOUND_RAM; - else + } + else { seq->sound = newlibadr(fd, sce->id.lib, seq->sound); + } if (seq->sound) { seq->sound->id.us++; seq->scene_sound = sound_add_scene_sound_defaults(sce, seq); diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index 9731854d68c..16e8b8904fa 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -102,8 +102,10 @@ typedef struct Strip { } Strip; /* The sequence structure is the basic struct used by any strip. each of the strips uses a different sequence structure.*/ -/* WATCH IT: first part identical to ID (for use in ipo's) */ +/* WATCH IT: first part identical to ID (for use in ipo's) + * the commend above is historic, probably we can drop the ID compatibility, but take care making this change */ +/* WATCH ITv2, this is really a 'Strip' in the UI!, name is highly confusing */ typedef struct Sequence { struct Sequence *next, *prev; void *tmp; /* tmp var for copying, and tagging for linked selection */ @@ -127,12 +129,14 @@ typedef struct Sequence { Strip *strip; struct Ipo *ipo DNA_DEPRECATED; /* old animation system, deprecated for 2.5 */ - struct Scene *scene; - struct Object *scene_camera; /* override scene camera */ + + /* these ID vars should never be NULL but can be when linked libs fail to load, so check on access */ + struct Scene *scene; + struct Object *scene_camera; /* override scene camera */ + struct MovieClip *clip; /* for MOVIECLIP strips */ + struct Mask *mask; /* for MASK strips */ struct anim *anim; /* for MOVIE strips */ - struct MovieClip *clip; /* for MOVIECLIP strips */ - struct Mask *mask; /* for MASK strips */ float effect_fader; float speed_fader; |