diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-02-26 08:59:26 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-02-26 08:59:26 +0300 |
commit | 72ceab8ab256ea53e364a2e9ae9ef3f62b634373 (patch) | |
tree | 73293b50d82a592db18281fed3b815eee78e6439 /source/blender/editors | |
parent | 7cb55a79d82d3e2e9d330368492210b17f6e1eac (diff) |
Cleanup: use early exit
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/physics/particle_edit_undo.c | 29 |
1 files changed, 16 insertions, 13 deletions
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) |