From 301c4bd09ad01f8ff6d7b8c7761edf1506b4e7e7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Jul 2012 22:19:19 +0000 Subject: [PATCH 1/5] code cleanup: minor edits --- source/blender/blenlib/BLI_fileops.h | 2 +- source/blender/blenlib/intern/storage.c | 2 +- source/blender/imbuf/intern/anim_movie.c | 2 +- source/blender/windowmanager/wm_window.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h index ca810ee5b93..ac0ec6a52a7 100644 --- a/source/blender/blenlib/BLI_fileops.h +++ b/source/blender/blenlib/BLI_fileops.h @@ -65,7 +65,7 @@ int BLI_is_dir(const char *path); int BLI_is_file(const char *path); void BLI_dir_create_recursive(const char *dir); double BLI_dir_free_space(const char *dir); -char *BLI_current_working_dir(char *dir, const int maxlen); +char *BLI_current_working_dir(char *dir, const size_t maxlen); unsigned int BLI_dir_contents(const char *dir, struct direntry **filelist); diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index d4f251d4f5e..965e8b5eec3 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -102,7 +102,7 @@ static struct ListBase dirbase_ = {NULL, NULL}; static struct ListBase *dirbase = &dirbase_; /* can return NULL when the size is not big enough */ -char *BLI_current_working_dir(char *dir, const int maxncpy) +char *BLI_current_working_dir(char *dir, const size_t maxncpy) { const char *pwd = getenv("PWD"); if (pwd) { diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index a908d4aa3b8..f0c2d754333 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -64,7 +64,7 @@ #include #endif -#include "BLI_blenlib.h" /* BLI_remlink BLI_filesize BLI_addtail +#include "BLI_blenlib.h" /* BLI_remlink BLI_file_descriptor_size BLI_addtail * BLI_countlist BLI_stringdec */ #include "BLI_utildefines.h" #include "BLI_math_base.h" diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h index 6fd4ced9c23..6360cfd4802 100644 --- a/source/blender/windowmanager/wm_window.h +++ b/source/blender/windowmanager/wm_window.h @@ -56,7 +56,7 @@ void wm_window_raise (wmWindow *win); void wm_window_lower (wmWindow *win); void wm_window_set_size (wmWindow *win, int width, int height); void wm_window_get_size (wmWindow *win, int *width_r, int *height_r); -void wm_window_get_size_ghost (wmWindow *win, int *width_r, int *height_r); +void wm_window_get_size_ghost(wmWindow *win, int *width_r, int *height_r); void wm_window_get_position (wmWindow *win, int *posx_r, int *posy_r); void wm_window_swap_buffers (wmWindow *win); From 4a33d7f210ab4007d3c590548cae74708cee11fc Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 2 Jul 2012 07:40:25 +0000 Subject: [PATCH 2/5] Fix related on #31984: Multires Displacement Bake creates ripples for each subidived face Skip applying subdivisions in cases when low resolution mesh is disabled and baking happens from higher level to higher level/ --- source/blender/editors/object/object_bake.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 810fe244984..e1c715952d1 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -616,13 +616,15 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima) CLAMP(ss_lvl, 0, 6); - smd.levels = smd.renderLevels = ss_lvl; - smd.flags |= eSubsurfModifierFlag_SubsurfUv; + if (ss_lvl > 0) { + smd.levels = smd.renderLevels = ss_lvl; + smd.flags |= eSubsurfModifierFlag_SubsurfUv; - if (bkr->simple) - smd.subdivType = ME_SIMPLE_SUBSURF; + if (bkr->simple) + smd.subdivType = ME_SIMPLE_SUBSURF; - height_data->ssdm = subsurf_make_derived_from_derived(bkr->lores_dm, &smd, NULL, 0); + height_data->ssdm = subsurf_make_derived_from_derived(bkr->lores_dm, &smd, NULL, 0); + } } height_data->origindex = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX); From ccf8c835ba5bb8aaaa044aff3dab5e8519f8fb36 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 2 Jul 2012 08:30:29 +0000 Subject: [PATCH 3/5] Fix #31961: Grease Pencil in VSE don't save the data Issue was caused by linking to grease pencil from direct_link* function which lead to NULL GP data because it's being read a way later. Link to GP data in lib_link* instead. --- source/blender/blenloader/intern/readfile.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index cb87ee7eb14..836f723327e 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5909,11 +5909,20 @@ static void direct_link_screen(FileData *fd, bScreen *sc) } } else if (sl->spacetype == SPACE_SEQ) { + /* grease pencil data is not a direct data and can't be linked from direct_link* + * functions, it should be linked from lib_link* funcrions instead + * + * otherwise it'll lead to lost grease data on open because it'll likely be + * read from file after all other users of grease pencil and newdataadr would + * simple return NULL here (sergey) + */ +#if 0 SpaceSeq *sseq = (SpaceSeq *)sl; if (sseq->gpd) { sseq->gpd = newdataadr(fd, sseq->gpd); direct_link_gpencil(fd, sseq->gpd); } +#endif } else if (sl->spacetype == SPACE_BUTS) { SpaceButs *sbuts = (SpaceButs *)sl; From e2e79b9e10a3ce854f43290f6b82c97ff0fef4b6 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 2 Jul 2012 09:57:31 +0000 Subject: [PATCH 4/5] Validate mesh selection stack in mesh_validate function Related on #31944: Blender crashes on switching to mesh edit mode --- .../blender/blenkernel/intern/mesh_validate.c | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 5d39811cba9..4528b748412 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -211,6 +211,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh, short verts_fixed = FALSE; short vert_weights_fixed = FALSE; + int msel_fixed = FALSE; int do_edge_recalc = FALSE; @@ -754,8 +755,6 @@ int BKE_mesh_validate_arrays(Mesh *mesh, } } - PRINT("BKE_mesh_validate: finished\n\n"); - # undef REMOVE_EDGE_TAG # undef IS_REMOVED_EDGE # undef REMOVE_LOOP_TAG @@ -779,7 +778,51 @@ int BKE_mesh_validate_arrays(Mesh *mesh, } } - return (verts_fixed || vert_weights_fixed || do_polyloop_free || do_edge_free || do_edge_recalc); + if (mesh && mesh->mselect) { + MSelect *msel; + int free_msel = FALSE; + + for (i = 0, msel = mesh->mselect; i < mesh->totselect; i++, msel++) { + int tot_elem; + + if (msel->index < 0) { + PRINT("Mesh select element %d type %d index is negative, " + "resetting selection stack.\n", i, msel->type); + free_msel = TRUE; + break; + } + + switch (msel->type) { + case ME_VSEL: + tot_elem = mesh->totvert; + break; + case ME_ESEL: + tot_elem = mesh->totedge; + break; + case ME_FSEL: + tot_elem = mesh->totface; + break; + } + + if (msel->index > tot_elem) { + PRINT("Mesh select element %d type %d index %d is larger than data array size %d, " + "resetting selection stack.\n", i, msel->type, msel->index, tot_elem); + + free_msel = TRUE; + break; + } + } + + if (free_msel) { + MEM_freeN(mesh->mselect); + mesh->mselect = NULL; + mesh->totselect = 0; + } + } + + PRINT("BKE_mesh_validate: finished\n\n"); + + return (verts_fixed || vert_weights_fixed || do_polyloop_free || do_edge_free || do_edge_recalc || msel_fixed); } static int mesh_validate_customdata(CustomData *data, short do_verbose, const short do_fixes) From 7963c4c35e964a2351da8b34f3f9db88551d934b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 2 Jul 2012 10:41:56 +0000 Subject: [PATCH 5/5] Fix #31970: Crash, whith Sequencer Swap Data-Function --- source/blender/editors/space_sequencer/sequencer_edit.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index bc8133cded6..7ed5c77ed1f 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2694,8 +2694,11 @@ static int sequencer_swap_data_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - sound_remove_scene_sound(scene, seq_act->scene_sound); - sound_remove_scene_sound(scene, seq_other->scene_sound); + if (seq_act->scene_sound) + sound_remove_scene_sound(scene, seq_act->scene_sound); + + if (seq_other->scene_sound) + sound_remove_scene_sound(scene, seq_other->scene_sound); seq_act->scene_sound = NULL; seq_other->scene_sound = NULL;