[Bf-blender-cvs] [72ceab8ab25] master: Cleanup: use early exit

Campbell Barton noreply at git.blender.org
Fri Feb 26 07:00:34 CET 2021


Commit: 72ceab8ab256ea53e364a2e9ae9ef3f62b634373
Author: Campbell Barton
Date:   Fri Feb 26 16:59:26 2021 +1100
Branches: master
https://developer.blender.org/rB72ceab8ab256ea53e364a2e9ae9ef3f62b634373

Cleanup: use early exit

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

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

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

diff --git a/source/blender/editors/physics/particle_edit_undo.c b/source/blender/editors/physics/particle_edit_undo.c
index c764a5fd80f..2c7b5c0de6a 100644
--- a/source/blender/editors/physics/particle_edit_undo.c
+++ b/source/blender/editors/physics/particle_edit_undo.c
@@ -265,22 +265,25 @@ static void particle_undosys_step_decode(struct bContext *C,
   ED_object_particle_edit_mode_enter_ex(depsgraph, scene, ob);
 
   PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
-  if (edit) {
-    undoptcache_to_editcache(&us->data, edit);
-    ParticleEditSettings *pset = &scene->toolsettings->particle;
-    if ((pset->flag & PE_DRAW_PART) != 0) {
-      psys_free_path_cache(NULL, edit);
-      BKE_particle_batch_cache_dirty_tag(edit->psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
-    }
-    DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
-
-    ED_undo_object_set_active_or_warn(scene, CTX_data_view_layer(C), ob, us_p->name, &LOG);
 
-    BLI_assert(particle_undosys_poll(C));
-  }
-  else {
+  /* While this shouldn't happen, entering particle edit-mode uses a more complex
+   * setup compared to most other modes which we can't ensure succeeds. */
+  if (UNLIKELY(edit == NULL)) {
     BLI_assert(0);
+    return;
   }
+
+  undoptcache_to_editcache(&us->data, edit);
+  ParticleEditSettings *pset = &scene->toolsettings->particle;
+  if ((pset->flag & PE_DRAW_PART) != 0) {
+    psys_free_path_cache(NULL, edit);
+    BKE_particle_batch_cache_dirty_tag(edit->psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
+  }
+  DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+
+  ED_undo_object_set_active_or_warn(scene, CTX_data_view_layer(C), ob, us_p->name, &LOG);
+
+  BLI_assert(particle_undosys_poll(C));
 }
 
 static void particle_undosys_step_free(UndoStep *us_p)



More information about the Bf-blender-cvs mailing list