Fix for [#25633] Particles display switching causes crash when Velocity disp. ON
authorJanne Karhu <jhkarh@gmail.com>
Sat, 15 Jan 2011 12:29:22 +0000 (12:29 +0000)
committerJanne Karhu <jhkarh@gmail.com>
Sat, 15 Jan 2011 12:29:22 +0000 (12:29 +0000)
* Particle draw data wasn't freed properly in some cases.
* Velocity + circle draw type also crashed due to missing null pointer check.

source/blender/editors/space_view3d/drawobject.c

index 26445c4d7422f67847de3f9f8db60dfa5c0284b4..8724f2f9def607009914c264b0d44e68f1a54e43 100644 (file)
@@ -3684,6 +3684,11 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
                pdd->nd= pdd->ndata;
                pdd->tot_vec_size= tot_vec_size;
        }
+       else if(psys->pdd) {
+               psys_free_pdd(psys);
+               MEM_freeN(psys->pdd);
+               pdd = psys->pdd = NULL;
+       }
 
        if(pdd) {
                pdd->ma_r = &ma_r;
@@ -3842,7 +3847,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
                        if(drawn) {
                                /* additional things to draw for each particle  */
                                /* (velocity, size and number)                                  */
-                               if((part->draw & PART_DRAW_VEL) && pdd->vedata){
+                               if((part->draw & PART_DRAW_VEL) && pdd && pdd->vedata){
                                        copy_v3_v3(pdd->ved,state.co);
                                        pdd->ved += 3;
                                        mul_v3_v3fl(vel, state.vel, timestep);