bugfix [#21055] Python: accessing ParticleEdit.hair causes segmentation violation
authorCampbell Barton <ideasman42@gmail.com>
Tue, 9 Feb 2010 20:03:05 +0000 (20:03 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 9 Feb 2010 20:03:05 +0000 (20:03 +0000)
source/blender/blenkernel/intern/object.c
source/blender/editors/physics/particle_edit.c

index 3be01e38368612ca15aaf3da2a3ba136916457bf..2ecb282a16e2fca096758459d56a1c71535860e1 100644 (file)
@@ -579,6 +579,7 @@ void unlink_object(Scene *scene, Object *ob)
                if(sce->id.lib==NULL) {
                        if(sce->camera==ob) sce->camera= NULL;
                        if(sce->toolsettings->skgen_template==ob) sce->toolsettings->skgen_template = NULL;
+                       if(sce->toolsettings->particle.object==ob) sce->toolsettings->particle.object= NULL;
 
 #ifdef DURIAN_CAMERA_SWITCH
                        {
index c2ead76ff3e2fef86aae33da01fe8538968c7703..f4486353e47ed24c0eedd78e77d4b5bb63fbc7ca 100644 (file)
@@ -191,7 +191,7 @@ int PE_start_edit(PTCacheEdit *edit)
 
 ParticleEditSettings *PE_settings(Scene *scene)
 {
-       return &scene->toolsettings->particle;
+       return scene->toolsettings ? &scene->toolsettings->particle : NULL;
 }
 
 /* always gets atleast the first particlesystem even if PSYS_CURRENT flag is not set
@@ -205,12 +205,12 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create)
        ListBase pidlist;
        PTCacheID *pid;
 
+       if(pset==NULL || pset->object==NULL)
+               return NULL;
+
        pset->scene = scene;
        pset->object = ob;
 
-       if(ob==NULL)
-               return NULL;
-
        BKE_ptcache_ids_from_object(&pidlist, ob);
 
        /* in the case of only one editable thing, set pset->edittype accordingly */