[Bf-blender-cvs] [82c3fdd559b] master: Fix T57907: Crash with hair when switching between object and edit mode

Sergey Sharybin noreply at git.blender.org
Fri Dec 21 14:39:52 CET 2018


Commit: 82c3fdd559b32d88881883b99cf441935401cf05
Author: Sergey Sharybin
Date:   Fri Dec 21 14:24:16 2018 +0100
Branches: master
https://developer.blender.org/rB82c3fdd559b32d88881883b99cf441935401cf05

Fix T57907: Crash with hair when switching between object and edit mode

Was only visible after going in and out (with some strokes inbetween)
hair edit mode. The edit structure was never freed during Blender
session for some reason. Now we free those when leaving particle
edit mode.

===================================================================

M	source/blender/editors/physics/particle_edit.c

===================================================================

diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index d5daaaa3812..33ed3336355 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -4810,6 +4810,21 @@ static bool particle_edit_toggle_poll(bContext *C)
 	        modifiers_findByType(ob, eModifierType_Softbody));
 }
 
+static void free_all_psys_edit(Object *object)
+{
+	for (ParticleSystem *psys = object->particlesystem.first;
+	     psys != NULL;
+	     psys = psys->next)
+	{
+		if (psys->edit != NULL) {
+			BLI_assert(psys->free_edit != NULL);
+			psys->free_edit(psys->edit);
+			psys->free_edit = NULL;
+			psys->edit = NULL;
+		}
+	}
+}
+
 static int particle_edit_toggle_exec(bContext *C, wmOperator *op)
 {
 	struct wmMsgBus *mbus = CTX_wm_message_bus(C);
@@ -4851,6 +4866,7 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op)
 	else {
 		ob->mode &= ~mode_flag;
 		toggle_particle_cursor(C, 0);
+		free_all_psys_edit(ob);
 		WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
 	}



More information about the Bf-blender-cvs mailing list