[Bf-blender-cvs] [ec77228f0f6] master: Fix T92402: copy_particle_systems use_active fails outside the Properties Editor

Philipp Oeser noreply at git.blender.org
Wed Oct 27 08:51:46 CEST 2021


Commit: ec77228f0f6a6205fea9437c85e618f7d779064c
Author: Philipp Oeser
Date:   Tue Oct 26 09:55:50 2021 +0200
Branches: master
https://developer.blender.org/rBec77228f0f6a6205fea9437c85e618f7d779064c

Fix T92402: copy_particle_systems use_active fails outside the
Properties Editor

Similar to rBf9308a585ecd, use `psys_get_current` if we cant get the
active psys from context (which is only defined for the Properties
Editor). Other solution would be to define a "particle_system" context
member in other editors, but for now, stick with the simplest solution.

thx @mano-wii for additional input

Maniphest Tasks: T92402

Differential Revision: https://developer.blender.org/D13000

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

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

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

diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index 3ac6dca3044..367d72b0ad7 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -1235,9 +1235,15 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op)
   const bool use_active = RNA_boolean_get(op->ptr, "use_active");
   Scene *scene = CTX_data_scene(C);
   Object *ob_from = ED_object_active_context(C);
-  ParticleSystem *psys_from =
-      use_active ? CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data :
-                   NULL;
+
+  ParticleSystem *psys_from = NULL;
+  if (use_active) {
+    psys_from = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data;
+    if (psys_from == NULL) {
+      /* Particle System context pointer is only valid in the Properties Editor. */
+      psys_from = psys_get_current(ob_from);
+    }
+  }
 
   int changed_tot = 0;
   int fail = 0;



More information about the Bf-blender-cvs mailing list