Merging r48470 through r48489 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 2 Jul 2012 11:29:55 +0000 (11:29 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 2 Jul 2012 11:29:55 +0000 (11:29 +0000)
source/blender/blenkernel/intern/mesh_validate.c
source/blender/blenlib/BLI_fileops.h
source/blender/blenlib/intern/storage.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/object/object_bake.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/imbuf/intern/anim_movie.c
source/blender/windowmanager/wm_window.h

index 5d39811cba9ab0df13e066eec8f82838fa1008dc..4528b748412d8f10effbcf131613e259ca716657 100644 (file)
@@ -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)
index ca810ee5b93f202bdb447f0ec72b469efe18805c..ac0ec6a52a706db18b16502f465a927972fe176a 100644 (file)
@@ -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);
 
index d4f251d4f5e35c7d36cbf138aefccce82ea132a8..965e8b5eec334fc2bd5e487184aacaf95aca23c2 100644 (file)
@@ -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) {
index 37e05623f2d9d0079f85fcc331fc539f50c65af6..60469a31a8c815ccedf4942973d9578ab8c8f20f 100644 (file)
@@ -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;
index 810fe2449841934d9375d1cfea0570bcaf6107c0..e1c715952d19954a4b43bc38c03a3fe2b4958c3c 100644 (file)
@@ -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);
index bc8133cded63b442b6a0505fa86478bbe8206f6d..7ed5c77ed1fe0bbcf4660e95ca741ef9ed5302e8 100644 (file)
@@ -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;
index a908d4aa3b80ea1e08b7426b5fa1b5a3ab63a660..f0c2d754333b84d1bb81214972c9d8f9589a929d 100644 (file)
@@ -64,7 +64,7 @@
 #include <io.h>
 #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"
index 6fd4ced9c23028f99acf114a6e7031213b2f4aea..6360cfd480223b7b20e26a66cb5a677b7fccff68 100644 (file)
@@ -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);