Revision: 53237
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53237
Author:   nazgul
Date:     2012-12-21 09:27:39 +0000 (Fri, 21 Dec 2012)
Log Message:
-----------
Fix #33640: Blender crashes when I click on "Connect Hair" in "Particles" pannel

Issue was caused by disabled particle system modifier, now connect hair
will check on that and give an error message if modifier is disabled.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/physics/particle_object.c

Modified: trunk/blender/source/blender/editors/physics/particle_object.c
===================================================================
--- trunk/blender/source/blender/editors/physics/particle_object.c      
2012-12-21 08:35:26 UTC (rev 53236)
+++ trunk/blender/source/blender/editors/physics/particle_object.c      
2012-12-21 09:27:39 UTC (rev 53237)
@@ -49,6 +49,7 @@
 #include "BKE_main.h"
 #include "BKE_particle.h"
 #include "BKE_pointcache.h"
+#include "BKE_report.h"
 
 
 #include "RNA_access.h"
@@ -625,7 +626,7 @@
        RNA_def_boolean(ot->srna, "all", 0, "All hair", "Disconnect all hair 
systems from the emitter mesh");
 }
 
-static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys)
+static int connect_hair(Scene *scene, Object *ob, ParticleSystem *psys)
 {
        ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
        ParticleData *pa;
@@ -642,8 +643,8 @@
        float hairmat[4][4], imat[4][4];
        float v[4][3], vec[3];
 
-       if (!psys || !psys->part || psys->part->type != PART_HAIR)
-               return;
+       if (!psys || !psys->part || psys->part->type != PART_HAIR || !psmd->dm)
+               return FALSE;
        
        edit= psys->edit;
        point=  edit ? edit->points : NULL;
@@ -724,6 +725,8 @@
        psys->flag &= ~PSYS_GLOBAL_HAIR;
 
        PE_update_object(scene, ob, 0);
+
+       return TRUE;
 }
 
 static int connect_hair_exec(bContext *C, wmOperator *op)
@@ -733,20 +736,26 @@
        PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", 
&RNA_ParticleSystem);
        ParticleSystem *psys= NULL;
        int all = RNA_boolean_get(op->ptr, "all");
+       int any_connected = FALSE;
 
        if (!ob)
                return OPERATOR_CANCELLED;
 
        if (all) {
                for (psys=ob->particlesystem.first; psys; psys=psys->next) {
-                       connect_hair(scene, ob, psys);
+                       any_connected |= connect_hair(scene, ob, psys);
                }
        }
        else {
                psys = ptr.data;
-               connect_hair(scene, ob, psys);
+               any_connected |= connect_hair(scene, ob, psys);
        }
 
+       if (!any_connected) {
+               BKE_report(op->reports, RPT_ERROR, "Can't disconnect hair if 
particle system modifier is disabled");
+               return OPERATOR_CANCELLED;
+       }
+
        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
 

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to